diff mbox series

[bug#45323] substitute: Reuse connections for '--query'.

Message ID 87tus7thy1.fsf@gnu.org
State Accepted
Headers show
Series [bug#45323] substitute: Reuse connections for '--query'. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Ludovic Courtès Dec. 27, 2020, 2:57 p.m. UTC
Hi!

Christopher Baines <mail@cbaines.net> skribis:

> The Guix Build Coordinator uses code from this script, and I'm sometimes
> seeing exceptions like [1] when running with these changes. This is when
> calling lookup-narinfos.
>
> 1:
> #<&compound-exception components: (#<&error> #<&irritants irritants: (#<gnutls-error-enum The specified session has been invalidated for some
> reason.> write_to_session_record_port)> #<&exception-with-kind-and-args kind: gnutls-error args: (#<gnutls-error-enum The specified session hasbeen invalidated for some reason.> write_to_session_record_port)>)>,
>
> When this happens, things seem to get stuck and retrying calling
> lookup-narinfos leads to the same exception. I'm guessing this might be
> happening because the broken connection is being cached and reused.

Ah, that looks like another thing that might break.  Does the patch
below help?

Thanks for reporting it,
Ludo’.

Comments

Christopher Baines Dec. 30, 2020, 10:55 p.m. UTC | #1
Ludovic Courtès <ludo@gnu.org> writes:

> Hi!
>
> Christopher Baines <mail@cbaines.net> skribis:
>
>> The Guix Build Coordinator uses code from this script, and I'm sometimes
>> seeing exceptions like [1] when running with these changes. This is when
>> calling lookup-narinfos.
>>
>> 1:
>> #<&compound-exception components: (#<&error> #<&irritants irritants: (#<gnutls-error-enum The specified session has been invalidated for some
>> reason.> write_to_session_record_port)> #<&exception-with-kind-and-args kind: gnutls-error args: (#<gnutls-error-enum The specified session hasbeen invalidated for some reason.> write_to_session_record_port)>)>,
>>
>> When this happens, things seem to get stuck and retrying calling
>> lookup-narinfos leads to the same exception. I'm guessing this might be
>> happening because the broken connection is being cached and reused.
>
> Ah, that looks like another thing that might break.  Does the patch
> below help?

I've tried using it, and I haven't spotted any problems yet, so I
believe so.

Thanks,

Chris
Ludovic Courtès Jan. 4, 2021, 10:55 a.m. UTC | #2
Hi,

Christopher Baines <mail@cbaines.net> skribis:

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

[...]

>>> #<&compound-exception components: (#<&error> #<&irritants irritants: (#<gnutls-error-enum The specified session has been invalidated for some
>>> reason.> write_to_session_record_port)> #<&exception-with-kind-and-args kind: gnutls-error args: (#<gnutls-error-enum The specified session hasbeen invalidated for some reason.> write_to_session_record_port)>)>,
>>>
>>> When this happens, things seem to get stuck and retrying calling
>>> lookup-narinfos leads to the same exception. I'm guessing this might be
>>> happening because the broken connection is being cached and reused.
>>
>> Ah, that looks like another thing that might break.  Does the patch
>> below help?
>
> I've tried using it, and I haven't spotted any problems yet, so I
> believe so.

Pushed as 9158020d7853b6e7925802e0d0a082801c680e8f, thanks!

Ludo’.
diff mbox series

Patch

diff --git a/guix/scripts/substitute.scm b/guix/scripts/substitute.scm
index 8084c89ae5..e53de8c304 100755
--- a/guix/scripts/substitute.scm
+++ b/guix/scripts/substitute.scm
@@ -43,6 +43,7 @@ 
                           (open-connection-for-uri
                            . guix:open-connection-for-uri)
                           store-path-abbreviation byte-count->string))
+  #:autoload   (gnutls) (error/invalid-session)
   #:use-module (guix progress)
   #:use-module ((guix build syscalls)
                 #:select (set-thread-name))
@@ -1054,9 +1055,12 @@  server certificates."
         ;; If PORT was cached and the server closed the connection in the
         ;; meantime, we get EPIPE.  In that case, open a fresh connection and
         ;; retry.  We might also get 'bad-response or a similar exception from
-        ;; (web response) later on, once we've sent the request.
+        ;; (web response) later on, once we've sent the request, or a
+        ;; ERROR/INVALID-SESSION from GnuTLS.
         (if (or (and (eq? key 'system-error)
                      (= EPIPE (system-error-errno `(,key ,@args))))
+                (and (eq? key 'gnutls-error)
+                     (eq? (first args) error/invalid-session))
                 (memq key '(bad-response bad-header bad-header-component)))
             (proc (open-connection uri #:fresh? #t))
             (apply throw key args))))))