Subject: Re: bug#42151: [PATCH 4/3] database: Do not use journal_model=WAL for the Hurd.

From: Ludovic Courtès <[email-masked]>
Date: Fri, 10 Jul 2020 14:03:08 +0200

Hi!

Jan Nieuwenhuizen <[email-masked]> skribis:

>>>From dc6f96fc7de50602fb28d7ad7b8cbff09e55f538 Mon Sep 17 00:00:00 2001
> From: "Jan (janneke) Nieuwenhuizen" <[email-masked]>
> Date: Fri, 3 Jul 2020 23:45:20 +0200
> Subject: [PATCH 4/3] database: Do not use journal_model=WAL for the Hurd.
> Content-Transfer-Encoding: 8bit
> Content-Type: text/plain; charset=UTF-8
>
> This fixes <https://bugs.gnu.org/42151>.
>
> * guix/store/database.scm (call-with-database): When building for the Hurd,
> do not set journal_model=WAL.
> ---
>  guix/store/database.scm | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/guix/store/database.scm b/guix/store/database.scm
> index a38e4d7e52..da46b0abce 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 <[email-masked]>
>  ;;; Copyright © 2018, 2020 Ludovic Courtès <[email-masked]>
> +;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <[email-masked]>
>  ;;;
>  ;;; 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)
> @@ -105,9 +108,12 @@ create it and initialize it as a new database."
>                       (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: <https://www.sqlite.org/wal.html>.
> -    (sqlite-exec db "PRAGMA journal_mode=WAL;")
> +    ;; Using WAL breaks for the Hurd <https://bugs.gnu.org/42151>.
> +    (unless (let-system (system target)
> +              (equal? target "i586-pc-gnu"))
> +      ;; Turn DB in "write-ahead log" mode, which should avoid SQLITE_LOCKED
> +      ;; errors when we have several readers: <https://www.sqlite.org/wal.html>.
> +      (sqlite-exec db "PRAGMA journal_mode=WAL;"))

I think this has the same effect as:

  (unless #t
    (sqlite-exec db "PRAGMA journal_mode=WAL;"))

because this code is not in a gexp, so ‘let-system’ evaluates to an
object (not #f), and that’s it, it’s never lowered and the ‘equal?’ call
is never made.

You want to disable WAL mode not just when running this code natively on
GNU/Hurd, but also when building a database that will eventually be used
on GNU/Hurd, right?

In that case, I think you’ll have to add, say, a #:wal-mode? parameter
to ‘call-with-database’ (defaulting to #true), and change the caller to
set it appropriately.  The caller, directly or indirectly, is in a gexp,
where you can use the ‘let-system’ expression above.

Does that make sense?

Thanks, and apologies for the delay!

Ludo’.