mirror of
https://github.com/minio/minio.git
synced 2026-02-04 18:00:15 -05:00
Don't replace caches that are receiving updates (#10834)
Keep caches while they are receiving updates. Move update code to separate function.
This commit is contained in:
@@ -99,8 +99,11 @@ func (m *metacache) canBeReplacedBy(other *metacache) bool {
|
||||
if other.status == scanStateNone || other.status == scanStateError {
|
||||
return false
|
||||
}
|
||||
if m.status == scanStateStarted && time.Since(m.lastUpdate) < metacacheMaxRunningAge {
|
||||
return false
|
||||
}
|
||||
// Keep it around a bit longer.
|
||||
if time.Since(m.lastHandout) < time.Hour {
|
||||
if time.Since(m.lastHandout) < time.Hour || time.Since(m.lastUpdate) < metacacheMaxRunningAge {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -138,6 +141,28 @@ func baseDirFromPrefix(prefix string) string {
|
||||
return b
|
||||
}
|
||||
|
||||
// update cache with new status.
|
||||
// The updates are conditional so multiple callers can update with different states.
|
||||
func (m *metacache) update(update metacache) {
|
||||
m.lastUpdate = UTCNow()
|
||||
|
||||
if m.status == scanStateStarted && update.status == scanStateSuccess {
|
||||
m.ended = UTCNow()
|
||||
m.endedCycle = update.endedCycle
|
||||
}
|
||||
|
||||
if m.status == scanStateStarted && update.status != scanStateStarted {
|
||||
m.status = update.status
|
||||
}
|
||||
|
||||
if m.error == "" && update.error != "" {
|
||||
m.error = update.error
|
||||
m.status = scanStateError
|
||||
m.ended = UTCNow()
|
||||
}
|
||||
m.fileNotFound = m.fileNotFound || update.fileNotFound
|
||||
}
|
||||
|
||||
// delete all cache data on disks.
|
||||
func (m *metacache) delete(ctx context.Context) {
|
||||
if m.bucket == "" || m.id == "" {
|
||||
|
||||
Reference in New Issue
Block a user