diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-06-10 20:50:22 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-06-10 20:50:22 +0100 |
commit | cef345bf0592c06e18154d9696f71324f11e9fd4 (patch) | |
tree | eadc161524c77276a58870966e85a6c999771cb8 /src | |
parent | 598d4cb0074658bd34f8f901745da3181fc566d4 (diff) | |
download | rspamd-cef345bf0592c06e18154d9696f71324f11e9fd4.tar.gz rspamd-cef345bf0592c06e18154d9696f71324f11e9fd4.zip |
[Minor] Sqlite: Try to fix messy transaction
Diffstat (limited to 'src')
-rw-r--r-- | src/libstat/backends/sqlite3_backend.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/libstat/backends/sqlite3_backend.c b/src/libstat/backends/sqlite3_backend.c index 626bb0988..f4254c779 100644 --- a/src/libstat/backends/sqlite3_backend.c +++ b/src/libstat/backends/sqlite3_backend.c @@ -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); |