d4a60db
From 33c8b214425c2860fdfe485d597e210b9723a792 Mon Sep 17 00:00:00 2001
d4a60db
Message-Id: <33c8b214425c2860fdfe485d597e210b9723a792.1653292401.git.pmatilai@redhat.com>
d4a60db
From: Panu Matilainen <pmatilai@redhat.com>
d4a60db
Date: Mon, 23 May 2022 10:42:13 +0300
d4a60db
Subject: [PATCH] Prevent uncontrolled sqlite WAL growth during large
d4a60db
 transactions
d4a60db
d4a60db
Sqlite WAL threshold of 1000 pages is way too low for rpmdb as a single
d4a60db
header often exceeds that, but disabling the checkpointing entirely can
d4a60db
cause the WAL to grow to multiple gigabytes during large distro update
d4a60db
transactions, which isn't healty either. Bump the threshold to 10000
d4a60db
pages which caps the WAL size to tens of megabytes, which hopefully
d4a60db
is a reasonable balance between performance on rotational disks (anybody
d4a60db
remember those?) and diskpace consumption.
d4a60db
d4a60db
Also drop no longer meaningful link to %_flush_io configuration.
d4a60db
---
d4a60db
 lib/backend/sqlite.c | 5 ++---
d4a60db
 1 file changed, 2 insertions(+), 3 deletions(-)
d4a60db
d4a60db
diff --git a/lib/backend/sqlite.c b/lib/backend/sqlite.c
d4a60db
index 31f77e845..d5389736b 100644
d4a60db
--- a/lib/backend/sqlite.c
d4a60db
+++ b/lib/backend/sqlite.c
d4a60db
@@ -180,9 +180,8 @@ static int sqlite_init(rpmdb rdb, const char * dbhome)
d4a60db
 		int one = 1;
d4a60db
 		/* Annoying but necessary to support non-privileged readers */
d4a60db
 		sqlite3_file_control(sdb, NULL, SQLITE_FCNTL_PERSIST_WAL, &one);
d4a60db
-
d4a60db
-		if (!rpmExpandNumeric("%{?_flush_io}"))
d4a60db
-		    sqlexec(sdb, "PRAGMA wal_autocheckpoint = 0");
d4a60db
+		/* Sqlite default threshold is way too low for rpmdb */
d4a60db
+		sqlexec(sdb, "PRAGMA wal_autocheckpoint = 10000");
d4a60db
 	    }
d4a60db
 	}
d4a60db
 
d4a60db
-- 
d4a60db
2.35.3
d4a60db