From ac3079f8cd56c5fb45d34f133613e433c64e2db2 Mon Sep 17 00:00:00 2001 From: Justin Traglia <95511699+jtraglia@users.noreply.github.com> Date: Wed, 17 Aug 2022 14:01:01 -0500 Subject: [PATCH] Add lock around unsafe append in goroutine (#11247) Co-authored-by: Raul Jordan --- tools/exploredb/main.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/exploredb/main.go b/tools/exploredb/main.go index 44862e575e..6cf0b4d236 100644 --- a/tools/exploredb/main.go +++ b/tools/exploredb/main.go @@ -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 {