mirror of
https://github.com/minio/minio.git
synced 2025-11-09 05:34:56 -05:00
verify RenameData() versions to be consistent (#15649)
xl.meta gets written and never rolled back, however we definitely need to validate the state that is persisted on the disk, if there are inconsistencies - more than write quorum we should return an error to the client - if write quorum was achieved however there are inconsistent xl.meta's we should simply trigger an MRF on them
This commit is contained in:
@@ -27,6 +27,30 @@ import (
|
||||
"github.com/minio/minio/internal/sync/errgroup"
|
||||
)
|
||||
|
||||
// figure out the most commonVersions across disk that satisfies
|
||||
// the 'writeQuorum' this function returns '0' if quorum cannot
|
||||
// be achieved and disks have too many inconsistent versions.
|
||||
func reduceCommonVersions(diskVersions []uint64, writeQuorum int) (commonVersions uint64) {
|
||||
diskVersionsCount := make(map[uint64]int)
|
||||
for _, versions := range diskVersions {
|
||||
diskVersionsCount[versions]++
|
||||
}
|
||||
|
||||
max := 0
|
||||
for versions, count := range diskVersionsCount {
|
||||
if max < count {
|
||||
max = count
|
||||
commonVersions = versions
|
||||
}
|
||||
}
|
||||
|
||||
if max >= writeQuorum {
|
||||
return commonVersions
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
// Returns number of errors that occurred the most (incl. nil) and the
|
||||
// corresponding error value. NB When there is more than one error value that
|
||||
// occurs maximum number of times, the error value returned depends on how
|
||||
|
||||
Reference in New Issue
Block a user