Keep transient lists while they are updating (#10826)

On extremely long running listings keep the transient list 15 minutes after last update instead of using start time.

Also don't do overlap checks on transient lists.
This commit is contained in:
Klaus Post 2020-11-04 08:01:33 -08:00 committed by GitHub
parent 1e11b4629f
commit f0819cce75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -297,27 +297,34 @@ func (b *bucketMetacache) cleanup() {
b.mu.RLock() b.mu.RLock()
for id, cache := range b.caches { for id, cache := range b.caches {
if b.transient && time.Since(cache.started) > time.Hour { if b.transient && time.Since(cache.lastUpdate) > 15*time.Minute && time.Since(cache.lastHandout) > 15*time.Minute {
// Keep transient caches only for 1 hour. // Keep transient caches only for 1 hour.
remove[id] = struct{}{} remove[id] = struct{}{}
continue
} }
if !cache.worthKeeping(currentCycle) { if !cache.worthKeeping(currentCycle) {
debugPrint("cache %s not worth keeping", id) debugPrint("cache %s not worth keeping", id)
remove[id] = struct{}{} remove[id] = struct{}{}
continue
} }
if cache.id != id { if cache.id != id {
logger.Info("cache ID mismatch %s != %s", id, cache.id) logger.Info("cache ID mismatch %s != %s", id, cache.id)
remove[id] = struct{}{} remove[id] = struct{}{}
continue
} }
if cache.bucket != b.bucket && !b.transient { if cache.bucket != b.bucket && !b.transient {
logger.Info("cache bucket mismatch %s != %s", b.bucket, cache.bucket) logger.Info("cache bucket mismatch %s != %s", b.bucket, cache.bucket)
remove[id] = struct{}{} remove[id] = struct{}{}
continue
} }
} }
// Check all non-deleted against eachother. // Check all non-deleted against eachother.
// O(n*n), but should still be rather quick. // O(n*n), but should still be rather quick.
for id, cache := range b.caches { for id, cache := range b.caches {
if b.transient {
break
}
if _, ok := remove[id]; ok { if _, ok := remove[id]; ok {
continue continue
} }