[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
04/04: installer: final: Delete SQLite WAL and shm files upon completion
From: |
guix-commits |
Subject: |
04/04: installer: final: Delete SQLite WAL and shm files upon completion. |
Date: |
Sat, 17 Dec 2022 19:18:14 -0500 (EST) |
civodul pushed a commit to branch version-1.4.0
in repository guix.
commit 495c50008be91429ebea3805e161a1e385a2a572
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Sun Dec 18 00:35:21 2022 +0100
installer: final: Delete SQLite WAL and shm files upon completion.
Previously, db.sqlite-{wal,shm} could be left behind after stopping
guix-daemon. When resuming installation, SQLite could end up behaving
as if transactions visible in the WAL file had been committed, in spite
of having restored SAVED-DATABASE.
Fixes <https://issues.guix.gnu.org/59784>.
Reported by pelzflorian (Florian Pelz) <pelzflorian@pelzflorian.de>.
* gnu/installer/final.scm (install-system): Before restarting
guix-daemon, delete db.sqlite-{wal,shm}.
---
gnu/installer/final.scm | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/gnu/installer/final.scm b/gnu/installer/final.scm
index f5601d8649..069426a3b8 100644
--- a/gnu/installer/final.scm
+++ b/gnu/installer/final.scm
@@ -221,10 +221,18 @@ or #f. Return #t on success and #f on failure."
;; alive.
(stop-service 'guix-daemon)
- ;; Restore the database and restart it.
+ ;; Restore the database and restart it. As part of restoring the
+ ;; database, remove the WAL and shm files in case they were left
+ ;; behind after guix-daemon was stopped. Failing to do so,
+ ;; sqlite might behave as if transactions that appear in the WAL
+ ;; file were committed. (See <https://www.sqlite.org/wal.html>.)
(installer-log-line "restoring store database from '~a'"
saved-database)
(copy-file saved-database database-file)
+ (for-each (lambda (suffix)
+ (false-if-exception
+ (delete-file (string-append database-file suffix))))
+ '("-wal" "-shm"))
(start-service 'guix-daemon)
;; Finally umount the cow-store and exit the container.