Fix scanner deadlock on lost global lock (#16726)

This commit is contained in:
Klaus Post
2023-03-01 06:34:45 +01:00
committed by GitHub
parent 47dfa62384
commit d07089ceac
2 changed files with 11 additions and 5 deletions

View File

@@ -412,9 +412,6 @@ func (er erasureObjects) nsScanner(ctx context.Context, buckets []BucketInfo, wa
for {
select {
case <-ctx.Done():
// Return without saving.
return
case <-t.C:
if cache.Info.LastUpdate.Equal(lastSave) {
continue
@@ -488,10 +485,13 @@ func (er erasureObjects) nsScanner(ctx context.Context, buckets []BucketInfo, wa
go func(name string) {
defer wg.Done()
for update := range updates {
bucketResults <- dataUsageEntryInfo{
select {
case <-ctx.Done():
case bucketResults <- dataUsageEntryInfo{
Name: name,
Parent: dataUsageRoot,
Entry: update,
}:
}
}
}(cache.Info.Name)
@@ -519,10 +519,14 @@ func (er erasureObjects) nsScanner(ctx context.Context, buckets []BucketInfo, wa
root = cache.flatten(*r)
}
t := time.Now()
bucketResults <- dataUsageEntryInfo{
select {
case <-ctx.Done():
return
case bucketResults <- dataUsageEntryInfo{
Name: cache.Info.Name,
Parent: dataUsageRoot,
Entry: root,
}:
}
// We want to avoid synchronizing up all writes in case
// the results are piled up.