From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 8Lg/Ela1CF9dCAAA0tVLHw (envelope-from ) for ; Fri, 10 Jul 2020 18:37:10 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id uK75DVa1CF9AHAAAbx9fmQ (envelope-from ) for ; Fri, 10 Jul 2020 18:37:10 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id B4F319404CB for ; Fri, 10 Jul 2020 18:37:09 +0000 (UTC) Received: from localhost ([::1]:56480 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jtxtU-0006vj-NF for larch@yhetil.org; Fri, 10 Jul 2020 14:37:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46326) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jtxtO-0006vV-1l for bug-guix@gnu.org; Fri, 10 Jul 2020 14:37:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:60120) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jtxtN-0006yH-Pm for bug-guix@gnu.org; Fri, 10 Jul 2020 14:37:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jtxtN-0001x2-Nc for bug-guix@gnu.org; Fri, 10 Jul 2020 14:37:01 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#42151: [PATCH v3 2/2] image: Do not set journal_model=WAL for the Hurd. Resent-From: "Jan (janneke) Nieuwenhuizen" Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Fri, 10 Jul 2020 18:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42151 X-GNU-PR-Package: guix X-GNU-PR-Keywords: patch To: 42151@debbugs.gnu.org Received: via spool by 42151-submit@debbugs.gnu.org id=B42151.15944061697432 (code B ref 42151); Fri, 10 Jul 2020 18:37:01 +0000 Received: (at 42151) by debbugs.gnu.org; 10 Jul 2020 18:36:09 +0000 Received: from localhost ([127.0.0.1]:43431 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jtxsR-0001vc-Se for submit@debbugs.gnu.org; Fri, 10 Jul 2020 14:36:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60554) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jtxsO-0001v7-QA for 42151@debbugs.gnu.org; Fri, 10 Jul 2020 14:36:02 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:40179) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jtxsI-0006ta-QO; Fri, 10 Jul 2020 14:35:55 -0400 Received: from [2001:980:1b4f:1:42d2:832d:bb59:862] (port=44692 helo=dundal.fritz.box) by fencepost.gnu.org with esmtpa (Exim 4.82) (envelope-from ) id 1jtxsI-0006le-Au; Fri, 10 Jul 2020 14:35:54 -0400 From: "Jan (janneke) Nieuwenhuizen" Date: Fri, 10 Jul 2020 20:35:51 +0200 Message-Id: <20200710183551.12807-2-janneke@gnu.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200710183551.12807-1-janneke@gnu.org> References: <20200710183551.12807-1-janneke@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -1.0 (-) X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Spam-Score: -0.01 X-TUID: XF7tWYXDSwmG This fixes . * gnu/system/images/hurd.scm (hurd-initialize-root-partition): Use #:wal-mode #f in call to ... * gnu/build/image.scm (initialize-root-partition): ... this, add #:wal-mode? parameter, pass it to ... (register-closure): ... this, add #:wal-mode? parameter, pass it to ... * guix/store/database.scm (with-database): ... this, add #:wal-mode? parameter, pass it to ... (call-with-database): ... this, add #:wal-mode? parameter; when set to #f, do not set journal_model=WAL. --- gnu/build/image.scm | 26 ++++++++++++++++---------- gnu/system/images/hurd.scm | 4 ++-- guix/store/database.scm | 29 ++++++++++++++++++++--------- 3 files changed, 38 insertions(+), 21 deletions(-) diff --git a/gnu/build/image.scm b/gnu/build/image.scm index e7b0418182..d8efa73f16 100644 --- a/gnu/build/image.scm +++ b/gnu/build/image.scm @@ -131,20 +131,23 @@ given CONFIG file." (define* (register-closure prefix closure #:key (deduplicate? #t) (reset-timestamps? #t) - (schema (sql-schema))) + (schema (sql-schema)) + (wal-mode? #t)) "Register CLOSURE in PREFIX, where PREFIX is the directory name of the target store and CLOSURE is the name of a file containing a reference graph as produced by #:references-graphs.. As a side effect, if RESET-TIMESTAMPS? is true, reset timestamps on store files and, if DEDUPLICATE? is true, -deduplicates files common to CLOSURE and the rest of PREFIX." +deduplicates files common to CLOSURE and the rest of PREFIX. Pass WAL-MODE? +to call-with-database." (let ((items (call-with-input-file closure read-reference-graph))) (parameterize ((sql-schema schema)) (with-database (store-database-file #:prefix prefix) db - (register-items db items - #:prefix prefix - #:deduplicate? deduplicate? - #:reset-timestamps? reset-timestamps? - #:registration-time %epoch))))) + #:wal-mode? wal-mode? + (register-items db items + #:prefix prefix + #:deduplicate? deduplicate? + #:reset-timestamps? reset-timestamps? + #:registration-time %epoch))))) (define* (initialize-efi-partition root #:key @@ -164,14 +167,16 @@ deduplicates files common to CLOSURE and the rest of PREFIX." (register-closures? #t) system-directory make-device-nodes + (wal-mode? #t) #:allow-other-keys) "Initialize the given ROOT directory. Use BOOTCFG and BOOTCFG-LOCATION to install the bootloader configuration. If REGISTER-CLOSURES? is true, register REFERENCES-GRAPHS in the store. If DEDUPLICATE? is true, then also deduplicate files common to CLOSURES and the -rest of the store when registering the closures. SYSTEM-DIRECTORY is the name -of the directory of the 'system' derivation." +rest of the store when registering the closures. SYSTEM-DIRECTORY is the name +of the directory of the 'system' derivation. Pass WAL-MODE? to +register-closure." (populate-root-file-system system-directory root) (populate-store references-graphs root) @@ -184,7 +189,8 @@ of the directory of the 'system' derivation." (register-closure root closure #:reset-timestamps? #t - #:deduplicate? deduplicate?)) + #:deduplicate? deduplicate? + #:wal-mode? wal-mode?)) references-graphs)) (when bootloader-installer diff --git a/gnu/system/images/hurd.scm b/gnu/system/images/hurd.scm index 31942e7386..4e1db37104 100644 --- a/gnu/system/images/hurd.scm +++ b/gnu/system/images/hurd.scm @@ -61,8 +61,8 @@ #~(lambda* (#:rest args) (apply initialize-root-partition (append args - (list #:make-device-nodes - make-hurd-device-nodes))))) + (list #:make-device-nodes make-hurd-device-nodes + #:wal-mode? #f))))) (define hurd-disk-image (image diff --git a/guix/store/database.scm b/guix/store/database.scm index a38e4d7e52..50b66ce282 100644 --- a/guix/store/database.scm +++ b/guix/store/database.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017, 2019 Caleb Ristvedt ;;; Copyright © 2018, 2020 Ludovic Courtès +;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen ;;; ;;; This file is part of GNU Guix. ;;; @@ -20,6 +21,7 @@ (define-module (guix store database) #:use-module (sqlite3) #:use-module (guix config) + #:use-module (guix gexp) #:use-module (guix serialization) #:use-module (guix store deduplication) #:use-module (guix base16) @@ -27,6 +29,7 @@ #:use-module (guix build syscalls) #:use-module ((guix build utils) #:select (mkdir-p executable-file?)) + #:use-module (guix utils) #:use-module (guix build store-copy) #:use-module (srfi srfi-1) #:use-module (srfi srfi-11) @@ -97,17 +100,20 @@ as specified by SQL-SCHEMA." (sqlite-exec db (call-with-input-file schema get-string-all))) -(define (call-with-database file proc) +(define* (call-with-database file proc #:key (wal-mode? #t)) "Pass PROC a database record corresponding to FILE. If FILE doesn't exist, -create it and initialize it as a new database." +create it and initialize it as a new database. Unless WAL-MODE? is set to #f, +set journal_mode=WAL." (let ((new? (and (not (file-exists? file)) (begin (mkdir-p (dirname file)) #t))) (db (sqlite-open file))) - ;; Turn DB in "write-ahead log" mode, which should avoid SQLITE_LOCKED - ;; errors when we have several readers: . - (sqlite-exec db "PRAGMA journal_mode=WAL;") + ;; Using WAL breaks for the Hurd . + (when wal-mode? + ;; Turn DB in "write-ahead log" mode, which should avoid SQLITE_LOCKED + ;; errors when we have several readers: . + (sqlite-exec db "PRAGMA journal_mode=WAL;")) ;; Install a busy handler such that, when the database is locked, sqlite ;; retries until 30 seconds have passed, at which point it gives up and @@ -200,10 +206,15 @@ prior to returning." ;; Default location of the store database. (string-append %store-database-directory "/db.sqlite")) -(define-syntax-rule (with-database file db exp ...) - "Open DB from FILE and close it when the dynamic extent of EXP... is left. -If FILE doesn't exist, create it and initialize it as a new database." - (call-with-database file (lambda (db) exp ...))) +(define-syntax with-database + (syntax-rules () + "Open DB from FILE and close it when the dynamic extent of EXP... is left. +If FILE doesn't exist, create it and initialize it as a new database. Pass +#:wal-mode? to call-with-database." + ((_ file db #:wal-mode? wal-mode? exp ...) + (call-with-database file (lambda (db) exp ...) #:wal-mode? wal-mode?)) + ((_ file db exp ...) + (call-with-database file (lambda (db) exp ...))))) (define (sqlite-finalize stmt) ;; As of guile-sqlite3 0.1.0, cached statements aren't reset when -- Jan Nieuwenhuizen | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com