scanner: Shuffle disks to scan (#12036)

Ensure random association between disk and bucket in each crawling
iteration to ensure that ILM applies correctly to objects not present in
all disks.
This commit is contained in:
Anis Elleuch 2021-04-12 15:55:40 +01:00 committed by GitHub
parent 641150f2a2
commit 8ab111cfb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -435,6 +435,11 @@ func (er erasureObjects) nsScanner(ctx context.Context, buckets []BucketInfo, bf
}
}()
// Shuffle disks to ensure a total randomness of bucket/disk association to ensure
// that objects that are not present in all disks are accounted and ILM applied.
r := rand.New(rand.NewSource(time.Now().UnixNano()))
r.Shuffle(len(disks), func(i, j int) { disks[i], disks[j] = disks[j], disks[i] })
// Start one scanner per disk
var wg sync.WaitGroup
wg.Add(len(disks))