db: Switch from 'synchronous = FULL' to 'synchronous = NORMAL'

As we're using WAL mode, it is not neccessary to use synchronous=FULL
but rely on synchronous=NORMAL mode while still guaranteeing database
consistency.

To do this, we can fix the typo in one of our two PRAGMA statements,
and remove the other.

See https://www.sqlite.org/pragma.html#pragma_synchronous for the
sqlite3 documentation on that topic.

Change-Id: Ie782f0fe90e7204c4d55cdb3948b728c348367d1
Closes: OS#5566
RelateD: OS#5564, OS#5563
This commit is contained in:
Harald Welte 2022-05-17 11:26:06 +02:00
parent d43c22ef65
commit 1d72e301cb
1 changed files with 1 additions and 10 deletions

View File

@ -562,7 +562,7 @@ int db_init(void *ctx, const char *fname, bool enable_sqlite_logging)
}
char *err_msg;
rc = sqlite3_exec(g_dbc->db, "PRAGMA journal_mode=WAL; PRAGMA synchonous = NORMAL;", 0, 0, &err_msg);
rc = sqlite3_exec(g_dbc->db, "PRAGMA journal_mode=WAL; PRAGMA synchronous = NORMAL;", 0, 0, &err_msg);
if (rc != SQLITE_OK) {
LOGP(DDB, LOGL_ERROR, "Unable to set Write-Ahead Logging: %s\n", err_msg);
sqlite3_free(err_msg);
@ -617,13 +617,6 @@ static int db_run_statements(struct db_context *dbc, const char **statements, si
return 0;
}
static int db_configure(struct db_context *dbc)
{
const char *sync_stmts[] = { "PRAGMA synchronous = FULL" };
return db_run_statements(dbc, sync_stmts, ARRAY_SIZE(sync_stmts));
}
int db_prepare(void)
{
unsigned int i;
@ -642,8 +635,6 @@ int db_prepare(void)
return -1;
}
db_configure(g_dbc);
/* prepare all SQL statements */
for (i = 0; i < ARRAY_SIZE(g_dbc->stmt); i++) {
rc = sqlite3_prepare_v2(g_dbc->db, stmt_sql[i], -1,