]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Use WAL in sqlite3.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 20 Jun 2015 21:31:31 +0000 (22:31 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 20 Jun 2015 21:31:31 +0000 (22:31 +0100)
src/libstat/backends/sqlite3_backend.c

index 112393f987817145163fdb4449cbd6cbdf2579db..d784cea2039e1ca5165322331a3a88cd0f449edb 100644 (file)
@@ -91,7 +91,7 @@ static struct rspamd_sqlite3_prstmt {
 {
        {
                .idx = RSPAMD_STAT_BACKEND_TRANSACTION_START,
-               .sql = "BEGIN TRANSACTION;",
+               .sql = "BEGIN IMMEDIATE TRANSACTION;",
                .args = "",
                .stmt = NULL,
                .result = SQLITE_DONE,
@@ -288,6 +288,7 @@ rspamd_sqlite3_opendb (const gchar *path, const ucl_object_t *opts,
        struct rspamd_stat_sqlite3_db *bk;
        sqlite3 *sqlite;
        gint rc, flags;
+       static const char sqlite_wal[] = "PRAGMA journal_mode=WAL;";
 
        flags = SQLITE_OPEN_READWRITE;
 
@@ -315,6 +316,10 @@ rspamd_sqlite3_opendb (const gchar *path, const ucl_object_t *opts,
                }
        }
 
+       if (sqlite3_exec (sqlite, sqlite_wal, NULL, NULL, NULL) != SQLITE_OK) {
+               msg_warn ("WAL mode is not supported, locking issues might occur");
+       }
+
        bk = g_slice_alloc0 (sizeof (*bk));
        bk->sqlite = sqlite;
        bk->prstmt = g_slice_alloc0 (sizeof (prepared_stmts));