Fix invalidated metacaches (#10784)

* Fix caches having EOF marked as a failure.
* Simplify cache updates.
* Provide context for checkMetacacheState failures.
* Log 499 when the client disconnects.
This commit is contained in:
Klaus Post
2020-10-30 09:33:16 -07:00
committed by GitHub
parent 7331659d3d
commit 6135f072d2
8 changed files with 206 additions and 140 deletions

View File

@@ -247,7 +247,7 @@ func (b *bucketMetacache) findCache(o listPathOptions) metacache {
b.caches[best.id] = best
b.updated = true
}
debugPrint("returning cached")
debugPrint("returning cached %s, status: %v, ended: %v", best.id, best.status, best.ended)
return best
}
if !o.Create {
@@ -348,16 +348,20 @@ func (b *bucketMetacache) updateCacheEntry(update metacache) (metacache, error)
}
existing.lastUpdate = UTCNow()
if existing.status == scanStateStarted && update.status != scanStateStarted {
existing.status = update.status
}
if existing.status == scanStateSuccess && update.status == scanStateSuccess {
if existing.status == scanStateStarted && update.status == scanStateSuccess {
existing.ended = UTCNow()
existing.endedCycle = update.endedCycle
}
if existing.status == scanStateStarted && update.status != scanStateStarted {
existing.status = update.status
}
if existing.error == "" && update.error != "" {
existing.error = update.error
existing.status = scanStateError
existing.ended = UTCNow()
}
existing.fileNotFound = existing.fileNotFound || update.fileNotFound
b.caches[update.id] = existing