emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#47897: closed ([PATCH] substitutes: Don't cache negative lookups or


From: GNU bug Tracking System
Subject: bug#47897: closed ([PATCH] substitutes: Don't cache negative lookups or transient errors.)
Date: Sun, 16 May 2021 21:32:01 +0000

Your message dated Sun, 16 May 2021 23:31:05 +0200
with message-id <87im3ifjs6.fsf_-_@gnu.org>
and subject line Re: bug#47897: [PATCH] substitutes: Don't cache negative 
lookups or transient errors.
has caused the debbugs.gnu.org bug report #47897,
regarding [PATCH] substitutes: Don't cache negative lookups or transient errors.
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
47897: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=47897
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: [PATCH] substitutes: Don't cache negative lookups or transient errors. Date: Mon, 19 Apr 2021 19:40:36 +0100
Caching these responses can delay users getting substitutes, since they'll
have to wait at least as long as the cache TTL to fetch the substitute, even
if it's available sooner.

* guix/substitutes.scm (%narinfo-negative-ttl, %narinfo-transient-error-ttl):
Remove variables.
(cache-narinfo!): Adjust to not use the negative TTL.
(fetch-narinfos): Don't cache non 200 status code responses.
---
 guix/substitutes.scm | 22 +++-------------------
 1 file changed, 3 insertions(+), 19 deletions(-)

diff --git a/guix/substitutes.scm b/guix/substitutes.scm
index 08f8c24efd..55daa6c964 100644
--- a/guix/substitutes.scm
+++ b/guix/substitutes.scm
@@ -70,14 +70,6 @@
   ;; 'Cache-Control' response header.
   (* 36 3600))
 
-(define %narinfo-negative-ttl
-  ;; Likewise, but for negative lookups---i.e., cached lookup failures (404).
-  (* 1 3600))
-
-(define %narinfo-transient-error-ttl
-  ;; Likewise, but for transient errors such as 504 ("Gateway timeout").
-  (* 10 60))
-
 (define %narinfo-cache-directory
   ;; A local cache of narinfos, to avoid going to the network.  Most of the
   ;; time, 'guix substitute' is called by guix-daemon as root and stores its
@@ -104,8 +96,7 @@ entry is stored in a sub-directory specific to CACHE-URL."
 
 (define (cache-narinfo! cache-url path narinfo ttl)
   "Cache locally NARNIFO for PATH, which originates from CACHE-URL, with the
-given TTL (a number of seconds or #f).  NARINFO may be #f, in which case it
-indicates that PATH is unavailable at CACHE-URL."
+given TTL (a number of seconds or #f)."
   (define now
     (current-time time-monotonic))
 
@@ -113,8 +104,7 @@ indicates that PATH is unavailable at CACHE-URL."
     `(narinfo (version 2)
               (cache-uri ,cache-uri)
               (date ,(time-second now))
-              (ttl ,(or ttl
-                        (if narinfo %narinfo-ttl %narinfo-negative-ttl)))
+              (ttl ,(or ttl %narinfo-ttl))
               (value ,(and=> narinfo narinfo->string))))
 
   (let ((file (narinfo-cache-file cache-url path)))
@@ -214,16 +204,10 @@ if file doesn't exist, and the narinfo otherwise."
                   (cache-narinfo! url (narinfo-path narinfo) narinfo ttl)
                   (cons narinfo result))
                 result))
-          (let* ((path      (uri-path (request-uri request)))
-                 (hash-part (basename
-                             (string-drop-right path 8)))) ;drop ".narinfo"
+          (begin
             (if len
                 (get-bytevector-n port len)
                 (read-to-eof port))
-            (cache-narinfo! url (hash-part->path hash-part) #f
-                            (if (or (= 404 code) (= 202 code))
-                                ttl
-                                %narinfo-transient-error-ttl))
             result))))
 
   (define (do-fetch uri)
-- 
2.30.1




--- End Message ---
--- Begin Message --- Subject: Re: bug#47897: [PATCH] substitutes: Don't cache negative lookups or transient errors. Date: Sun, 16 May 2021 23:31:05 +0200 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Hi,

Christopher Baines <mail@cbaines.net> skribis:

> The patches you've sent look good.

Pushed as 938ffcbb0589adc07dc12c79eda3e1e2bb9e7cf8 (I was generous and
lowered ‘%narinfo-negative-ttl’ to 10mn :-)).

Thanks,
Ludo’.


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]