[arvados] updated: 2.6.0-263-gf8c4f2428

git repository hosting git at public.arvados.org
Wed Jun 14 21:17:45 UTC 2023


Summary of changes:
 services/keep-web/handler.go      | 18 ++++++++++++++++--
 services/keep-web/handler_test.go |  1 +
 2 files changed, 17 insertions(+), 2 deletions(-)

       via  f8c4f242893020def3623aecb14a4aa9bf98d79e (commit)
      from  3ed8b54804c2993fde6feeabde8717cb69387598 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit f8c4f242893020def3623aecb14a4aa9bf98d79e
Author: Tom Clegg <tom at curii.com>
Date:   Wed Jun 14 17:17:18 2023 -0400

    20559: Garbage collect unused per-collection mutexes.
    
    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 c5a1705ec..00fa24d9d 100644
--- a/services/keep-web/handler.go
+++ b/services/keep-web/handler.go
@@ -18,6 +18,7 @@ import (
 	"strconv"
 	"strings"
 	"sync"
+	"time"
 
 	"git.arvados.org/arvados.git/lib/cmd"
 	"git.arvados.org/arvados.git/lib/webdavfs"
@@ -36,8 +37,9 @@ type handler struct {
 	Cluster   *arvados.Cluster
 	setupOnce sync.Once
 
-	lockMtx sync.Mutex
-	lock    map[string]*sync.RWMutex
+	lockMtx    sync.Mutex
+	lock       map[string]*sync.RWMutex
+	lockTidied time.Time
 }
 
 var urlPDHDecoder = strings.NewReplacer(" ", "+", "-", "+")
@@ -963,9 +965,21 @@ func (h *handler) determineCollection(fs arvados.CustomFileSystem, path string)
 	return nil, ""
 }
 
+var lockTidyInterval = time.Minute * 10
+
 func (h *handler) collectionLocker(collectionID string) *sync.RWMutex {
 	h.lockMtx.Lock()
 	defer h.lockMtx.Unlock()
+	if time.Since(h.lockTidied) > lockTidyInterval {
+		// Periodically delete all locks that aren't in use.
+		h.lockTidied = time.Now()
+		for id, locker := range h.lock {
+			if locker.TryLock() {
+				locker.Unlock()
+				delete(h.lock, id)
+			}
+		}
+	}
 	locker := h.lock[collectionID]
 	if locker == nil {
 		locker = new(sync.RWMutex)
diff --git a/services/keep-web/handler_test.go b/services/keep-web/handler_test.go
index e7f8559c2..3b957c5a0 100644
--- a/services/keep-web/handler_test.go
+++ b/services/keep-web/handler_test.go
@@ -1627,6 +1627,7 @@ func (s *IntegrationSuite) TestUploadLoggingPermission(c *check.C) {
 }
 
 func (s *IntegrationSuite) TestConcurrentWrites(c *check.C) {
+	lockTidyInterval = time.Second
 	client := arvados.NewClientFromEnv()
 	client.AuthToken = arvadostest.ActiveTokenV2
 	// Start small, and increase concurrency (2^2, 4^2, ...)

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list