]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Sqlite: Try to fix messy transaction
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 10 Jun 2019 19:50:22 +0000 (20:50 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 10 Jun 2019 19:50:22 +0000 (20:50 +0100)
src/libstat/backends/sqlite3_backend.c

index 626bb09884317ca097092878fc446a66aae6fee8..f4254c779ba58ed64cf7aaadfd37feb8774d15f3 100644 (file)
@@ -487,13 +487,13 @@ rspamd_sqlite3_opendb (rspamd_mempool_t *pool,
        /* Check tokenizer configuration */
 
        while ((ret = rspamd_sqlite3_run_prstmt (pool, bk->sqlite, bk->prstmt,
-                       RSPAMD_STAT_BACKEND_TRANSACTION_START_EXCL)) == SQLITE_BUSY &&
+                       RSPAMD_STAT_BACKEND_TRANSACTION_START_IM)) == SQLITE_BUSY &&
                        ++ntries <= max_tries) {
                nanosleep (&sleep_ts, NULL);
        }
 
        if (ret != SQLITE_OK) {
-               msg_err_pool ("failed to stard transaction: %d, %s", ret,
+               msg_err_pool ("failed to start transaction: %d, %s", ret,
                                sqlite3_errmsg (bk->sqlite));
                sqlite3_close (bk->sqlite);
                g_free (bk);
@@ -505,6 +505,15 @@ rspamd_sqlite3_opendb (rspamd_mempool_t *pool,
                        RSPAMD_STAT_BACKEND_LOAD_TOKENIZER, &sz64, &tk_conf) != SQLITE_OK ||
                        sz64 == 0) {
 
+               rspamd_sqlite3_run_prstmt (pool, bk->sqlite, bk->prstmt,
+                               RSPAMD_STAT_BACKEND_TRANSACTION_COMMIT);
+
+               while ((ret = rspamd_sqlite3_run_prstmt (pool, bk->sqlite, bk->prstmt,
+                               RSPAMD_STAT_BACKEND_TRANSACTION_START_EXCL)) == SQLITE_BUSY &&
+                          ++ntries <= max_tries) {
+                       nanosleep (&sleep_ts, NULL);
+               }
+
                msg_info_pool ("absent tokenizer conf in %s, creating a new one",
                                bk->fname);
                g_assert (stcf->clcf->tokenizer != NULL);