[arvados] created: 2.7.3-1-g95eb3c6016
git repository hosting
git at public.arvados.org
Fri May 31 19:28:52 UTC 2024
at 95eb3c6016471b04f4781aac41686891b8b2898c (commit)
commit 95eb3c6016471b04f4781aac41686891b8b2898c
Author: Tom Clegg <tom at curii.com>
Date: Tue Apr 23 09:51:38 2024 -0400
21697: Don't hold session lock while processing read requests.
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>
diff --git a/services/keep-web/handler.go b/services/keep-web/handler.go
index 123c4fe34d..a81ce1fdab 100644
--- a/services/keep-web/handler.go
+++ b/services/keep-web/handler.go
@@ -432,11 +432,18 @@ func (h *handler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) {
return
}
defer f.Close()
- defer sess.Release()
collectionDir, sessionFS, session, tokenUser = f, fs, sess, user
break
}
+
+ releaseSession := func() {}
+ if session != nil {
+ var releaseSessionOnce sync.Once
+ releaseSession = func() { releaseSessionOnce.Do(func() { session.Release() }) }
+ }
+ defer releaseSession()
+
if forceReload && collectionDir != nil {
err := collectionDir.Sync()
if err != nil {
@@ -524,6 +531,7 @@ func (h *handler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodGet || r.Method == http.MethodHead {
targetfnm := fsprefix + strings.Join(pathParts[stripParts:], "/")
if fi, err := sessionFS.Stat(targetfnm); err == nil && fi.IsDir() {
+ releaseSession() // because we won't be writing anything
if !strings.HasSuffix(r.URL.Path, "/") {
h.seeOtherWithCookie(w, r, r.URL.Path+"/", credentialsOK)
} else {
@@ -593,6 +601,15 @@ func (h *handler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) {
collectionDir.Splice(snap)
return nil
}}
+ } else {
+ // When writing, we need to block session renewal
+ // until we're finished, in order to guarantee the
+ // effect of the write is visible in future responses.
+ // But if we're not writing, we can release the lcok
+ // early. This enables us to keep renewing sessions
+ // and processing more requests even if a slow client
+ // takes a long time to download a large file.
+ releaseSession()
}
if r.Method == http.MethodGet {
applyContentDispositionHdr(w, r, basename, attachment)
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list