]> source.dussan.org Git - rspamd.git/commitdiff
Add more diagnostic to fuzzy errors
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 24 Nov 2015 14:11:57 +0000 (14:11 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 24 Nov 2015 14:11:57 +0000 (14:11 +0000)
src/libserver/fuzzy_backend.c
src/plugins/fuzzy_check.c

index 86902d05c9289fabd30faca80546979fbb3d6e92..611d212c4016a1488519c82923dceb4f65fcc51e 100644 (file)
@@ -595,11 +595,15 @@ rspamd_fuzzy_backend_add (struct rspamd_fuzzy_backend *backend,
 
        if (rc == SQLITE_OK) {
                /* We need to increase weight */
-               if (rc == SQLITE_OK) {
-                       rc = rspamd_fuzzy_backend_run_stmt (backend, TRUE,
-                                       RSPAMD_FUZZY_BACKEND_UPDATE,
-                                       (gint64) cmd->value,
-                                       cmd->digest);
+               rc = rspamd_fuzzy_backend_run_stmt (backend, TRUE,
+                               RSPAMD_FUZZY_BACKEND_UPDATE,
+                               (gint64) cmd->value,
+                               cmd->digest);
+               if (rc != SQLITE_OK) {
+                       msg_warn_fuzzy_backend ("cannot update hash to %d -> "
+                                       "%*xs: %s", (gint) cmd->flag,
+                                       (gint) sizeof (cmd->digest), cmd->digest,
+                                       sqlite3_errmsg (backend->db));
                }
        }
        else {
@@ -617,16 +621,29 @@ rspamd_fuzzy_backend_add (struct rspamd_fuzzy_backend *backend,
                                        shcmd = (const struct rspamd_fuzzy_shingle_cmd *) cmd;
 
                                        for (i = 0; i < RSPAMD_SHINGLE_SIZE; i++) {
-                                               rspamd_fuzzy_backend_run_stmt (backend, TRUE,
+                                               rc = rspamd_fuzzy_backend_run_stmt (backend, TRUE,
                                                                RSPAMD_FUZZY_BACKEND_INSERT_SHINGLE,
                                                                shcmd->sgl.hashes[i], i, id);
                                                msg_debug_fuzzy_backend ("add shingle %d -> %L: %L",
                                                                i,
                                                                shcmd->sgl.hashes[i],
                                                                id);
+
+                                               if (rc != SQLITE_OK) {
+                                                       msg_warn_fuzzy_backend ("cannot add shingle %d -> "
+                                                                       "%L: %L: %s", i,
+                                                                       shcmd->sgl.hashes[i],
+                                                                       id, sqlite3_errmsg (backend->db));
+                                               }
                                        }
                                }
                        }
+                       else {
+                               msg_warn_fuzzy_backend ("cannot add hash to %d -> "
+                                               "%*xs: %s", (gint)cmd->flag,
+                                               (gint)sizeof (cmd->digest), cmd->digest,
+                                               sqlite3_errmsg (backend->db));
+                       }
 
                        rspamd_fuzzy_backend_cleanup_stmt (backend,
                                        RSPAMD_FUZZY_BACKEND_INSERT);
@@ -638,6 +655,10 @@ rspamd_fuzzy_backend_add (struct rspamd_fuzzy_backend *backend,
                                RSPAMD_FUZZY_BACKEND_TRANSACTION_COMMIT);
        }
        else {
+               msg_warn_fuzzy_backend ("cannot commit hash to %d -> "
+                               "%*xs: %s", (gint) cmd->flag,
+                               (gint) sizeof (cmd->digest), cmd->digest,
+                               sqlite3_errmsg (backend->db));
                rspamd_fuzzy_backend_run_stmt (backend, TRUE,
                                RSPAMD_FUZZY_BACKEND_TRANSACTION_ROLLBACK);
        }
@@ -666,8 +687,19 @@ rspamd_fuzzy_backend_del (struct rspamd_fuzzy_backend *backend,
        if (rc == SQLITE_OK) {
                rc = rspamd_fuzzy_backend_run_stmt (backend, TRUE,
                                RSPAMD_FUZZY_BACKEND_TRANSACTION_COMMIT);
+
+               if (rc != SQLITE_OK) {
+                       msg_warn_fuzzy_backend ("cannot commit delete hash from %d -> "
+                                       "%*xs: %s", (gint) cmd->flag,
+                                       (gint) sizeof (cmd->digest), cmd->digest,
+                                       sqlite3_errmsg (backend->db));
+               }
        }
        else {
+               msg_warn_fuzzy_backend ("cannot delete hash from %d -> "
+                               "%*xs: %s", (gint) cmd->flag,
+                               (gint) sizeof (cmd->digest), cmd->digest,
+                               sqlite3_errmsg (backend->db));
                rspamd_fuzzy_backend_run_stmt (backend, TRUE,
                                RSPAMD_FUZZY_BACKEND_TRANSACTION_ROLLBACK);
        }
index 7e03009f991f50dbd6caa6a226869328eca10372..be1b556c83137b3c4f14914de66fb6fc62d098a2 100644 (file)
@@ -1251,9 +1251,10 @@ fuzzy_generate_commands (struct rspamd_task *task, struct fuzzy_rule *rule,
 
                /* Check length of part */
                if (fuzzy_module_ctx->min_bytes > part->content->len) {
-                       msg_info_task ("<%s>, part is shorter than %d symbols, skip fuzzy "
-                                                       "check",
-                               task->message_id, fuzzy_module_ctx->min_bytes);
+                       msg_info_task ("<%s>, part is shorter than %d bytes (%d bytes), "
+                                       "skip fuzzy check",
+                                       task->message_id, fuzzy_module_ctx->min_bytes,
+                                       part->content->len);
                        continue;
                }