X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/9acc8cb9cd9ca4429712b0d31b647e9a6ecf2d96..21a93d6e30f152c52e3952e56c9e498bdb695a8c:/services/keep-web/cache.go diff --git a/services/keep-web/cache.go b/services/keep-web/cache.go index d5fdc4997e..b08abad85d 100644 --- a/services/keep-web/cache.go +++ b/services/keep-web/cache.go @@ -276,7 +276,7 @@ func (c *cache) pruneSessions() { now := time.Now() var size int64 keys := c.sessions.Keys() - for _, token := range keys { + for idx, token := range keys { ent, ok := c.sessions.Peek(token) if !ok { continue @@ -284,6 +284,7 @@ func (c *cache) pruneSessions() { s := ent.(*cachedSession) if s.expire.Before(now) { c.sessions.Remove(token) + keys[idx] = "" continue } if fs, ok := s.fs.Load().(arvados.CustomFileSystem); ok { @@ -294,6 +295,12 @@ func (c *cache) pruneSessions() { // least frequently used entries (which Keys() returns last). for i := len(keys) - 1; i >= 0; i-- { token := keys[i] + if token == "" { + // removed this session in the loop above; + // don't prune it, even if it's already been + // reinserted. + continue + } if size <= c.cluster.Collections.WebDAVCache.MaxCollectionBytes/2 { break } @@ -500,7 +507,7 @@ func (c *cache) GetTokenUser(token string) (*arvados.User, error) { c.metrics.apiCalls.Inc() var current arvados.User - err = sess.client.RequestAndDecode(¤t, "GET", "/arvados/v1/users/current", nil, nil) + err = sess.client.RequestAndDecode(¤t, "GET", "arvados/v1/users/current", nil, nil) if err != nil { return nil, err }