diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-12-22 16:38:16 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-12-22 16:38:16 +0000 |
commit | 5c634505b897822e110c32afe33d3ef2f55444cb (patch) | |
tree | 6a36224c3ab39bf9af6b5644e014052749156b81 | |
parent | 07d6070ead1579494e251c654f9424ec184b6851 (diff) | |
download | rspamd-5c634505b897822e110c32afe33d3ef2f55444cb.tar.gz rspamd-5c634505b897822e110c32afe33d3ef2f55444cb.zip |
Add wal checkpoints to bayes backend
-rw-r--r-- | src/libstat/backends/sqlite3_backend.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/libstat/backends/sqlite3_backend.c b/src/libstat/backends/sqlite3_backend.c index c980ddf54..e6ef68a23 100644 --- a/src/libstat/backends/sqlite3_backend.c +++ b/src/libstat/backends/sqlite3_backend.c @@ -896,6 +896,7 @@ rspamd_sqlite3_finalize_learn (struct rspamd_task *task, gpointer runtime, { struct rspamd_stat_sqlite3_rt *rt = runtime; struct rspamd_stat_sqlite3_db *bk; + gint rc, wal_frames, wal_checkpointed, mode; g_assert (rt != NULL); bk = rt->db; @@ -906,7 +907,24 @@ rspamd_sqlite3_finalize_learn (struct rspamd_task *task, gpointer runtime, bk->in_transaction = FALSE; } - return; +#ifdef SQLITE_OPEN_WAL +#ifdef SQLITE_CHECKPOINT_TRUNCATE + mode = SQLITE_CHECKPOINT_TRUNCATE; +#elif defined(SQLITE_CHECKPOINT_RESTART) + mode = SQLITE_CHECKPOINT_RESTART; +#elif defined(SQLITE_CHECKPOINT_FULL) + mode = SQLITE_CHECKPOINT_FULL; +#endif + /* Perform wal checkpoint (might be long) */ + if (sqlite3_wal_checkpoint_v2 (bk->sqlite, + NULL, + mode, + &wal_frames, + &wal_checkpointed) != SQLITE_OK) { + msg_warn_task ("cannot commit checkpoint: %s", + sqlite3_errmsg (bk->sqlite)); + } +#endif } gulong |