From 1d72e301cbac3ff63a00b607d13e34ac993615b8 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Tue, 17 May 2022 11:26:06 +0200 Subject: [PATCH] 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 --- src/libmsc/db.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/libmsc/db.c b/src/libmsc/db.c index 000002a3d..07081d54f 100644 --- a/src/libmsc/db.c +++ b/src/libmsc/db.c @@ -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,