Subject: ‘guix publish --cache’ can lose its daemon connection

From: Ludovic Courtès <[email-masked]>
Date: Wed, 04 Nov 2020 15:48:52 +0100

With the introduction of “cache bypass” for ‘guix publish --cache’ in
commit 2b2ab7796ac186d88060793b8873fc0e21462758, ‘guix publish’ can
crash like so:

--8<---------------cut here---------------start------------->8---
$ sudo guix publish -u ludo --cache=/tmp/cache --cache-bypass-threshold=30M
guix publish: publishing /gnu/store on 0.0.0.0, port 8080
guix publish: using 'gzip' compression method, level 3
  C-c C-z
[1]+  Haltigita               sudo guix publish -u ludo --cache=/tmp/cache --cache-bypass-threshold=30M
$ bg
[1]+ sudo guix publish -u ludo --cache=/tmp/cache --cache-bypass-threshold=30M &
$ wget -O - http://localhost:8080/nar/gzip/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-foo
--2020-11-04 15:42:50--  http://localhost:8080/nar/gzip/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-foo
Ni solvigas localhost (localhost)... 127.0.0.1
Konektado al localhost (localhost)|127.0.0.1|:8080... konektita.
HTTP peto sendita, ni atendas respondon... GET /nar/gzip/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-foo
404 Not Found
2020-11-04 15:42:50 ERARO 404: Not Found.

$ wget -O - http://localhost:8080/n8awazyldv9hbzb7pjcw76hiifmvrpvd.narinfo
--2020-11-04 15:43:13--  http://localhost:8080/n8awazyldv9hbzb7pjcw76hiifmvrpvd.narinfo
Ni solvigas localhost (localhost)... 127.0.0.1
Konektado al localhost (localhost)|127.0.0.1|:8080... konektita.
HTTP peto sendita, ni atendas respondon... GET /n8awazyldv9hbzb7pjcw76hiifmvrpvd.narinfo
In guix/scripts/publish.scm:
    455:4  5 (render-narinfo/cached #<store-connection 256.99 7f24e…> …)
   460:12  4 (_ . _)
In guix/store.scm:
   1020:9  3 (_ #<store-connection 256.99 7f24eff0e320> "n8awazyldv9…")
    916:4  2 (flush)
In unknown file:
           1 (put-bytevector #<input-output: socket 15> #vu8(29 0 …) …)
In ice-9/boot-9.scm:
  1669:16  0 (raise-exception _ #:continuable? _)
In procedure fport_write: Rompita dukto
500 Internal Server Error
2020-11-04 15:43:13 ERARO 500: Internal Server Error.

$ wget -O - http://localhost:8080/n8awazyldv9hbzb7pjcw76hiifmvrpvd.narinfo
--2020-11-04 15:43:15--  http://localhost:8080/n8awazyldv9hbzb7pjcw76hiifmvrpvd.narinfo
Ni solvigas localhost (localhost)... 127.0.0.1
Konektado al localhost (localhost)|127.0.0.1|:8080... konektita.
HTTP peto sendita, ni atendas respondon... GET /n8awazyldv9hbzb7pjcw76hiifmvrpvd.narinfo
In guix/scripts/publish.scm:
    455:4  5 (render-narinfo/cached #<store-connection 256.99 7f24e…> …)
   460:12  4 (_ . _)
In guix/store.scm:
   1020:9  3 (_ #<store-connection 256.99 7f24eff0e320> "n8awazyldv9…")
    916:4  2 (flush)
In unknown file:
           1 (put-bytevector #<input-output: socket 15> #vu8(29 0 …) …)
In ice-9/boot-9.scm:
  1669:16  0 (raise-exception _ #:continuable? _)
In procedure fport_write: Rompita dukto
500 Internal Server Error
2020-11-04 15:43:15 ERARO 500: Internal Server Error.

--8<---------------cut here---------------end--------------->8---

The first wget here, leads to this call in ‘render-nar/cached’:

  (hash-part->path store "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee")
  ⇒ ""

and in turn to:

  (bypass-cache? store "")
    (query-path-info store "")

at which point the daemon throws and closes the connection.

Further attempts to access the store all lead to EPIPE as shown above.
At this point, ‘guix publish’ can only serve what’s already cached.

Ludo’.