Add lock around unsafe append in goroutine (#11247)

Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
This commit is contained in:
Justin Traglia
2022-08-17 14:01:01 -05:00
committed by GitHub
parent cb8f6423e0
commit ac3079f8cd

View File

@@ -179,9 +179,12 @@ func readBucketStat(dbNameWithPath string, statsC chan<- *bucketStat) {
// get a list of all the existing buckets.
var buckets []string
var bucketsMut sync.Mutex
if viewErr1 := db.View(func(tx *bolt.Tx) error {
return tx.ForEach(func(name []byte, buc *bolt.Bucket) error {
bucketsMut.Lock()
buckets = append(buckets, string(name))
bucketsMut.Unlock()
return nil
})
}); viewErr1 != nil {