mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
Return NumVersions in quorum when available (#19766)
Similar to https://github.com/minio/minio/pull/17925
This commit is contained in:
committed by
GitHub
parent
fc4561c64c
commit
1228d6bf1a
@@ -344,9 +344,14 @@ func findFileInfoInQuorum(ctx context.Context, metaArr []FileInfo, modTime time.
|
||||
return FileInfo{}, InsufficientReadQuorum{Err: errErasureReadQuorum, Type: RQInconsistentMeta}
|
||||
}
|
||||
|
||||
// Find the successor mod time in quorum, otherwise leave the
|
||||
// candidate's successor modTime as found
|
||||
succModTimeMap := make(map[time.Time]int)
|
||||
// objProps represents properties that go beyond a single version
|
||||
type objProps struct {
|
||||
succModTime time.Time
|
||||
numVersions int
|
||||
}
|
||||
// Find the successor mod time and numVersions in quorum, otherwise leave the
|
||||
// candidate as found
|
||||
otherPropsMap := make(counterMap[objProps])
|
||||
var candidate FileInfo
|
||||
var found bool
|
||||
for i, hash := range metaHashes {
|
||||
@@ -356,24 +361,21 @@ func findFileInfoInQuorum(ctx context.Context, metaArr []FileInfo, modTime time.
|
||||
candidate = metaArr[i]
|
||||
found = true
|
||||
}
|
||||
succModTimeMap[metaArr[i].SuccessorModTime]++
|
||||
props := objProps{
|
||||
succModTime: metaArr[i].SuccessorModTime,
|
||||
numVersions: metaArr[i].NumVersions,
|
||||
}
|
||||
otherPropsMap[props]++
|
||||
}
|
||||
}
|
||||
}
|
||||
var succModTime time.Time
|
||||
var smodTimeQuorum bool
|
||||
for smodTime, count := range succModTimeMap {
|
||||
if count >= quorum {
|
||||
smodTimeQuorum = true
|
||||
succModTime = smodTime
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if found {
|
||||
if smodTimeQuorum {
|
||||
candidate.SuccessorModTime = succModTime
|
||||
candidate.IsLatest = succModTime.IsZero()
|
||||
// Update candidate FileInfo with succModTime and numVersions in quorum when available
|
||||
if props, ok := otherPropsMap.GetValueWithQuorum(quorum); ok {
|
||||
candidate.SuccessorModTime = props.succModTime
|
||||
candidate.IsLatest = props.succModTime.IsZero()
|
||||
candidate.NumVersions = props.numVersions
|
||||
}
|
||||
return candidate, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user