From: "Joshua Watt" <JPEWhacker@gmail.com>
To: openembedded-core@lists.openembedded.org
Cc: Joshua Watt <JPEWhacker@gmail.com>
Subject: [pseudo][PATCH] db: Use WAL mode for on-disk database
Date: Fri, 31 Jul 2020 09:00:43 -0500 [thread overview]
Message-ID: <20200731140043.29659-1-JPEWhacker@gmail.com> (raw)
If the in-memory database is not being used, enable WAL mode on the
database to ensure that the database is resilient to pseudo shutting
down unexpectedly (or being terminated by the OS). This allows projects
to make the reliability vs. performance tradeoff: If they want
performance they can use the in-memory database; if they want resilience
they can disable the in-memory database and WAL will prevent database
corruption.
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
pseudo_db.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/pseudo_db.c b/pseudo_db.c
index 92e4f50..ebf6e08 100644
--- a/pseudo_db.c
+++ b/pseudo_db.c
@@ -158,11 +158,24 @@ static struct sql_index {
static char *file_pragmas[] = {
"PRAGMA legacy_file_format = OFF;",
- "PRAGMA journal_mode = OFF;",
+#ifdef USE_MEMORY_DB
/* the default page size produces painfully bad behavior
* for memory databases with some versions of sqlite.
*/
"PRAGMA page_size = 8192;",
+ "PRAGMA journal_mode = OFF;",
+#else
+ /* Use WAL mode when using the on-disk database. If user care about
+ * performance, they can use the in-memory database, but if they care
+ * more about resilience, they can disable it and WAL mode will prevent
+ * corruption of the on-disk database (for a slight performance
+ * penalty). Note that the database still keeps synchronous to OFF,
+ * meaning its resilient to the pseudo process crashing or being killed
+ * unexpectedly, but not to the OS crashing and losing buffered disk
+ * state
+ */
+ "PRAGMA journal_mode = WAL;",
+#endif
"PRAGMA locking_mode = EXCLUSIVE;",
/* Setting this to NORMAL makes pseudo noticably slower
* than fakeroot, but is perhaps more secure. However,
--
2.27.0
next reply other threads:[~2020-07-31 14:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-31 14:00 Joshua Watt [this message]
2020-07-31 14:32 ` ✗ patchtest: failure for db: Use WAL mode for on-disk database Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200731140043.29659-1-JPEWhacker@gmail.com \
--to=jpewhacker@gmail.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox