From: "Ludovic Courtès" <ludo@gnu.org>
To: Julien Lepiller <julien@lepiller.eu>
Cc: 36375@debbugs.gnu.org
Subject: bug#36375: [PATCH] Re: ‘guix package’ should lock the profile
Date: Wed, 06 Nov 2019 14:24:54 +0100 [thread overview]
Message-ID: <87mud95e8p.fsf@gnu.org> (raw)
In-Reply-To: <20191026000806.7eb6342b@sybil.lepiller.eu> (Julien Lepiller's message of "Sat, 26 Oct 2019 00:08:06 +0200")
Hello!
Julien Lepiller <julien@lepiller.eu> skribis:
>From 5d86226f318a111cc1bdf5a6f044c6f540f51b45 Mon Sep 17 00:00:00 2001
> From: Julien Lepiller <julien@lepiller.eu>
> Date: Fri, 25 Oct 2019 21:39:21 +0200
> Subject: [PATCH] guix: package: lock profiles when processing them.
>
> * guix/scripts/package.scm (process-actions): Get a per-profile lock to
> prevent concurrent actions on profiles.
> * guix/build/syscalls.scm (with-file-lock/no-wait): New procedure.
> (lock-file): Take a #:wait? key.
Nice! Could you make the syscalls.scm changes a separate patch?
> +(define (call-with-file-lock/no-wait file thunk handler)
> + (let ((port (catch 'system-error
> + (lambda ()
> + (catch 'flock-error
> + (lambda ()
> + (lock-file file #:wait? #f))
> + handler))
> + (lambda args
> + ;; When using the statically-linked Guile in the initrd,
> + ;; 'fcntl-flock' returns ENOSYS unconditionally. Ignore
> + ;; that error since we're typically the only process running
> + ;; at this point.
> + (if (or (= ENOSYS (system-error-errno args)) (= 'flock-error args))
Please remove tabs. :-)
This is wrong because (1) ‘args’ is always a list, and (2) ‘=’ is
defined for numbers, not for symbols and lists.
I think you actually want to catch two exceptions here: ‘system-error’
and ‘flock-error’. For that, you have to do:
(catch #t
(lambda ()
(lock-file …))
(lambda (key . args)
(match key
('flock-error …)
('system-error
(if (= ENOSYS (system-error-errno (cons key args)))
…))
(_
(apply throw key args)))))
Does that make sense?
> + ;; First, acquire a lock on the profile, to ensure only one guix process
> + ;; is modifying it at a time.
> + (with-file-lock/no-wait
> + (string-append profile ".lock")
Nitpick: I’d move the lock file name on the same line as
‘with-file-lock/no-wait’.
> + (lambda (key . args)
> + (leave (G_ "profile ~a is locked by another guix process.~%")
> + profile))
s/guix// and remove the trailing period.
Could you add a test for that in tests/guix-package.sh?
One way to do it may be to do something like:
echo '(sleep 60) > /…/manifest.scm
guix package -m /…/manifest.scm -p whatever &
pid=$!
if guix install emacs -p whatever; then false; else true; fi
kill $pid
Could you send updated patches?
Thanks!
Ludo’.
next prev parent reply other threads:[~2019-11-06 13:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-25 14:10 bug#36375: ‘guix package’ should lock the profile Ludovic Courtès
2019-10-25 19:44 ` bug#36375: [PATCH] " Julien Lepiller
2019-10-25 21:21 ` Ludovic Courtès
2019-10-25 22:08 ` Julien Lepiller
2019-11-06 13:24 ` Ludovic Courtès [this message]
2019-11-07 21:19 ` Julien Lepiller
2019-11-08 20:03 ` Ludovic Courtès
2019-11-08 21:03 ` Julien Lepiller
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=87mud95e8p.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=36375@debbugs.gnu.org \
--cc=julien@lepiller.eu \
/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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.