rspamd_mempool_t *pool;
};
+static const gdouble sql_sleep_time = 0.1;
+static const guint max_retries = 10;
+
#define msg_err_fuzzy_backend(...) rspamd_default_log_function (G_LOG_LEVEL_CRITICAL, \
backend->pool->tag.tagname, backend->pool->tag.uid, \
G_STRFUNC, \
sqlite3_stmt *stmt;
int i;
const char *argtypes;
+ guint retries = 0;
+ struct timespec ts;
if (idx < 0 || idx >= RSPAMD_FUZZY_BACKEND_MAX) {
}
va_end (ap);
+
+retry:
retcode = sqlite3_step (stmt);
if (retcode == prepared_stmts[idx].result) {
return SQLITE_OK;
}
else if (retcode != SQLITE_DONE) {
+ if (retcode == SQLITE_BUSY && retries++ < max_retries) {
+ double_to_ts (sql_sleep_time, &ts);
+ nanosleep (&ts, NULL);
+ goto retry;
+ }
+
msg_debug_fuzzy_backend ("failed to execute query %s: %d, %s", prepared_stmts[idx].sql,
retcode, sqlite3_errmsg (backend->db));
}
#define double_to_tv(dbl, tv) do { (tv)->tv_sec = (int)(dbl); (tv)->tv_usec = \
((dbl) - (int)(dbl)) * 1000 * 1000; \
} while (0)
+#define double_to_ts(dbl, ts) do { (ts)->tv_sec = (int)(dbl); (ts)->tv_nsec = \
+ ((dbl) - (int)(dbl)) * 1e9; \
+} while (0)
#define tv_to_msec(tv) ((tv)->tv_sec * 1000LLU + (tv)->tv_usec / 1000LLU)
#define tv_to_double(tv) ((tv)->tv_sec + (tv)->tv_usec / 1e6f)
#define ts_to_usec(ts) ((ts)->tv_sec * 1000000LLU + \