]> source.dussan.org Git - rspamd.git/commitdiff
Use WAL for fuzzy storage as well.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 29 Jun 2015 14:42:53 +0000 (15:42 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 29 Jun 2015 14:43:20 +0000 (15:43 +0100)
src/libserver/fuzzy_backend.c

index c59fa6133b3053a963345dd700e6d91b22c924bb..0cf2f8cfa98144ccb8ce13d65e323625dfa56052 100644 (file)
@@ -377,6 +377,8 @@ rspamd_fuzzy_backend_open_db (const gchar *path, GError **err)
 {
        struct rspamd_fuzzy_backend *bk;
        sqlite3 *sqlite;
+       static const char sqlite_wal[] = "PRAGMA journal_mode=WAL;",
+                       fallback_journal[] = "PRAGMA journal_mode=OFF;";
        int rc;
 
        if ((rc = sqlite3_open_v2 (path, &sqlite,
@@ -402,6 +404,11 @@ rspamd_fuzzy_backend_open_db (const gchar *path, GError **err)
                                prepared_stmts[RSPAMD_FUZZY_BACKEND_COUNT].stmt, 0);
        }
 
+       if (sqlite3_exec (sqlite, sqlite_wal, NULL, NULL, NULL) != SQLITE_OK) {
+               msg_warn ("WAL mode is not supported, locking issues might occur");
+               sqlite3_exec (sqlite, fallback_journal, NULL, NULL, NULL);
+       }
+
        rspamd_fuzzy_backend_run_simple (RSPAMD_FUZZY_BACKEND_TRANSACTION_START,
                                bk, NULL);