unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* bug#58485: [shepherd] Restarting guix-publish fails
@ 2022-10-13  7:51 Lars-Dominik Braun
  2022-10-13  9:28 ` Liliana Marie Prikler
  2022-11-17  8:24 ` Ludovic Courtès
  0 siblings, 2 replies; 8+ messages in thread
From: Lars-Dominik Braun @ 2022-10-13  7:51 UTC (permalink / raw)
  To: 58485; +Cc: Ludovic Courtès

Hi,

it seems that `herd restart guix-publish` stopped working after the
introduction of socket activation into shepherd. This is a problem,
because I restart guix-publish automatically after unattended-upgrades. It
fails with the following error for me:

---snip---
Backtrace:
           7 (primitive-load "/gnu/store/7xrg2sbb529ki6hv99n27svg0fi?")
In ice-9/boot-9.scm:
    724:2  6 (call-with-prompt ("prompt") #<procedure 7f8173184940 ?> ?)
  1752:10  5 (with-exception-handler _ _ #:unwind? _ # _)
In ice-9/eval.scm:
    619:8  4 (_ #(#(#<directory (guile-user) 7f817318ac80>)))
In ice-9/boot-9.scm:
   260:13  3 (for-each #<procedure restart-service (name)> _)
In gnu/services/herd.scm:
    168:4  2 (invoke-action guix-publish restart () #<procedure 7f81?>)
    176:7  1 (failure)
In ice-9/boot-9.scm:
  1685:16  0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
ERROR:
  1. &action-exception-error:
      service: guix-publish
      action: start
      key: system-error
      args: ("bind" "~A" ("Address already in use") (98))
---snap---

Note that due to the socket activation you must visit the URL at least
once to start up the guix-publish process. Otherwise a restart will
work fine. It also works fine the second time I invoke `herd restart
guix-publish`, because `guix-publish` is dead by that time.

Looking at an strace shepherd is indeed trying to kill `guix-publish`
and re-bind to the same address:

---snip---
1     read(23, "(shepherd-command (version 0) (action restart) (service guix-publish) (arguments ()) (directory \"/root\"))", 1024) = 105
1     getpgid(18096)                    = 18096
1     getpgid(0)                        = 0
1     kill(-18096, SIGTERM)             = 0
1     newfstatat(AT_FDCWD, "/etc/localtime", {st_mode=S_IFREG|0444, st_size=2298, ...}, 0) = 0
1     write(17, "shepherd[1]: Service guix-publish has been stopped.\n", 52) = 52
1     socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP) = 36
1     setsockopt(36, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
1     bind(36, {sa_family=AF_INET, sin_port=htons(8082), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EADDRINUSE (Address already in use)
1     write(23, "(reply (version 0) (result #f) (error (error (version 0) action-exception start guix-publish system-error (\"bind\" \"~A\" (\"Address already in use\") (98)))) (messages (\"Service guix-publish has been stopped.\")))", 208) = 208
1     close(23)
---snap---

The obvious explanation would be that stopping does not wait for the
process to actually exit. make-kill-destructor does not waitpid it seems
and 'running is set unconditionally to #f after 'stop has finished.

Cheers,
Lars





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#58485: [shepherd] Restarting guix-publish fails
  2022-10-13  7:51 bug#58485: [shepherd] Restarting guix-publish fails Lars-Dominik Braun
@ 2022-10-13  9:28 ` Liliana Marie Prikler
  2022-10-13 11:35   ` Lars-Dominik Braun
  2022-11-17  8:24 ` Ludovic Courtès
  1 sibling, 1 reply; 8+ messages in thread
From: Liliana Marie Prikler @ 2022-10-13  9:28 UTC (permalink / raw)
  To: Lars-Dominik Braun, 58485; +Cc: Ludovic Courtès

Am Donnerstag, dem 13.10.2022 um 09:51 +0200 schrieb Lars-Dominik
Braun:
> The obvious explanation would be that stopping does not wait for the
> process to actually exit. make-kill-destructor does not waitpid it
> seems and 'running is set unconditionally to #f after 'stop has
> finished.
Shouldn't [1] address this very issue?

[1]
http://git.savannah.gnu.org/cgit/guix.git/commit/?id=2a37f174becbafd70591f6eb1d98493c5c1df0e2




^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#58485: [shepherd] Restarting guix-publish fails
  2022-10-13  9:28 ` Liliana Marie Prikler
@ 2022-10-13 11:35   ` Lars-Dominik Braun
  2022-10-13 13:38     ` Liliana Marie Prikler
  0 siblings, 1 reply; 8+ messages in thread
From: Lars-Dominik Braun @ 2022-10-13 11:35 UTC (permalink / raw)
  To: Liliana Marie Prikler; +Cc: Ludovic Courtès, 58485

Hi Liliana,

> Shouldn't [1] address this very issue?
> [1]
> http://git.savannah.gnu.org/cgit/guix.git/commit/?id=2a37f174becbafd70591f6eb1d98493c5c1df0e2
no, if the process is running make-systemd-destructor is just an alias
for make-kill-destructor. So it does not matter which one we use in this case.

Lars




^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#58485: [shepherd] Restarting guix-publish fails
  2022-10-13 11:35   ` Lars-Dominik Braun
@ 2022-10-13 13:38     ` Liliana Marie Prikler
  2022-10-14  6:18       ` Lars-Dominik Braun
  0 siblings, 1 reply; 8+ messages in thread
From: Liliana Marie Prikler @ 2022-10-13 13:38 UTC (permalink / raw)
  To: Lars-Dominik Braun; +Cc: Ludovic Courtès, 58485

Am Donnerstag, dem 13.10.2022 um 13:35 +0200 schrieb Lars-Dominik
Braun:
> Hi Liliana,
> 
> > Shouldn't [1] address this very issue?
> > [1]
> > http://git.savannah.gnu.org/cgit/guix.git/commit/?id=2a37f174becbafd70591f6eb1d98493c5c1df0e2
> no, if the process is running make-systemd-destructor is just an
> alias for make-kill-destructor. So it does not matter which one we
> use in this case.
Ahh, so the issue is that shepherd waits neither for the process to be
actually killed nor for the socket to become available, isn't it?




^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#58485: [shepherd] Restarting guix-publish fails
  2022-10-13 13:38     ` Liliana Marie Prikler
@ 2022-10-14  6:18       ` Lars-Dominik Braun
  2022-10-14  6:57         ` Liliana Marie Prikler
  0 siblings, 1 reply; 8+ messages in thread
From: Lars-Dominik Braun @ 2022-10-14  6:18 UTC (permalink / raw)
  To: Liliana Marie Prikler; +Cc: Ludovic Courtès, 58485

Hi,

> Ahh, so the issue is that shepherd waits neither for the process to be
> actually killed nor for the socket to become available, isn't it?
I would argue it’s the former, but having either of them would solve
the problem, I think.

Lars





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#58485: [shepherd] Restarting guix-publish fails
  2022-10-14  6:18       ` Lars-Dominik Braun
@ 2022-10-14  6:57         ` Liliana Marie Prikler
  0 siblings, 0 replies; 8+ messages in thread
From: Liliana Marie Prikler @ 2022-10-14  6:57 UTC (permalink / raw)
  To: Lars-Dominik Braun; +Cc: Ludovic Courtès, 58485

Am Freitag, dem 14.10.2022 um 08:18 +0200 schrieb Lars-Dominik Braun:
> Hi,
> 
> > Ahh, so the issue is that shepherd waits neither for the process to
> > be
> > actually killed nor for the socket to become available, isn't it?
> I would argue it’s the former, but having either of them would solve
> the problem, I think.
I think you need both: if the process is killed, but the socket
remains, you need to clean it up.  As far as I'm aware, that does not
happen automatically.

Cheers




^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#58485: [shepherd] Restarting guix-publish fails
  2022-10-13  7:51 bug#58485: [shepherd] Restarting guix-publish fails Lars-Dominik Braun
  2022-10-13  9:28 ` Liliana Marie Prikler
@ 2022-11-17  8:24 ` Ludovic Courtès
  2022-11-17 10:19   ` Ludovic Courtès
  1 sibling, 1 reply; 8+ messages in thread
From: Ludovic Courtès @ 2022-11-17  8:24 UTC (permalink / raw)
  To: Lars-Dominik Braun; +Cc: 58485

Hi,

Lars-Dominik Braun <lars@6xq.net> skribis:

> 1     kill(-18096, SIGTERM)             = 0
> 1     newfstatat(AT_FDCWD, "/etc/localtime", {st_mode=S_IFREG|0444, st_size=2298, ...}, 0) = 0
> 1     write(17, "shepherd[1]: Service guix-publish has been stopped.\n", 52) = 52
> 1     socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP) = 36
> 1     setsockopt(36, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
> 1     bind(36, {sa_family=AF_INET, sin_port=htons(8082), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EADDRINUSE (Address already in use)
> 1     write(23, "(reply (version 0) (result #f) (error (error (version 0) action-exception start guix-publish system-error (\"bind\" \"~A\" (\"Address already in use\") (98)))) (messages (\"Service guix-publish has been stopped.\")))", 208) = 208
> 1     close(23)
> ---snap---
>
> The obvious explanation would be that stopping does not wait for the
> process to actually exit. make-kill-destructor does not waitpid it seems
> and 'running is set unconditionally to #f after 'stop has finished.

Indeed.  This is fixed by Shepherd commit
d97592f58603ff51cb280ae57d413c8731e601b3, which will be in the upcoming
0.9.3 release.

Thanks,
Ludo’.




^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#58485: [shepherd] Restarting guix-publish fails
  2022-11-17  8:24 ` Ludovic Courtès
@ 2022-11-17 10:19   ` Ludovic Courtès
  0 siblings, 0 replies; 8+ messages in thread
From: Ludovic Courtès @ 2022-11-17 10:19 UTC (permalink / raw)
  To: Lars-Dominik Braun; +Cc: 58485-done

Ludovic Courtès <ludo@gnu.org> skribis:

> Indeed.  This is fixed by Shepherd commit
> d97592f58603ff51cb280ae57d413c8731e601b3, which will be in the upcoming
> 0.9.3 release.

The Shepherd 0.9.3 has landed in Guix commit
283d7318c5b312d7129adb6dbeea6ad205ce89d1.

Ludo’.




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-11-17 10:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-13  7:51 bug#58485: [shepherd] Restarting guix-publish fails Lars-Dominik Braun
2022-10-13  9:28 ` Liliana Marie Prikler
2022-10-13 11:35   ` Lars-Dominik Braun
2022-10-13 13:38     ` Liliana Marie Prikler
2022-10-14  6:18       ` Lars-Dominik Braun
2022-10-14  6:57         ` Liliana Marie Prikler
2022-11-17  8:24 ` Ludovic Courtès
2022-11-17 10:19   ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).