mirror of https://github.com/minio/minio.git
fix: two different scanner update races (#12615)
This commit is contained in:
parent
f706671568
commit
a7e2a1a38b
|
@ -484,11 +484,11 @@ func (er erasureObjects) nsScanner(ctx context.Context, buckets []BucketInfo, bf
|
||||||
updates := make(chan dataUsageEntry, 1)
|
updates := make(chan dataUsageEntry, 1)
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func(name string) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
for update := range updates {
|
for update := range updates {
|
||||||
bucketResults <- dataUsageEntryInfo{
|
bucketResults <- dataUsageEntryInfo{
|
||||||
Name: cache.Info.Name,
|
Name: name,
|
||||||
Parent: dataUsageRoot,
|
Parent: dataUsageRoot,
|
||||||
Entry: update,
|
Entry: update,
|
||||||
}
|
}
|
||||||
|
@ -496,7 +496,7 @@ func (er erasureObjects) nsScanner(ctx context.Context, buckets []BucketInfo, bf
|
||||||
console.Debugln("bucket", bucket.Name, "got update", update)
|
console.Debugln("bucket", bucket.Name, "got update", update)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}(cache.Info.Name)
|
||||||
|
|
||||||
// Calc usage
|
// Calc usage
|
||||||
before := cache.Info.LastUpdate
|
before := cache.Info.LastUpdate
|
||||||
|
|
|
@ -188,6 +188,7 @@ func (s *storageRESTServer) NSScannerHandler(w http.ResponseWriter, r *http.Requ
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
for update := range updates {
|
for update := range updates {
|
||||||
// Write true bool to indicate update.
|
// Write true bool to indicate update.
|
||||||
|
var err error
|
||||||
if err = respW.WriteBool(true); err == nil {
|
if err = respW.WriteBool(true); err == nil {
|
||||||
err = update.EncodeMsg(respW)
|
err = update.EncodeMsg(respW)
|
||||||
}
|
}
|
||||||
|
@ -211,6 +212,10 @@ func (s *storageRESTServer) NSScannerHandler(w http.ResponseWriter, r *http.Requ
|
||||||
if err = respW.WriteBool(false); err == nil {
|
if err = respW.WriteBool(false); err == nil {
|
||||||
err = usageInfo.EncodeMsg(respW)
|
err = usageInfo.EncodeMsg(respW)
|
||||||
}
|
}
|
||||||
|
if err != nil {
|
||||||
|
resp.CloseWithError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
resp.CloseWithError(respW.Flush())
|
resp.CloseWithError(respW.Flush())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue