Skip to content

Commit b6e98ae

Browse files
fix: found races in accessing globalLocalDrives (minio#19069)
make a copy before accessing globalLocalDrives Bonus: update console v0.46.0 Signed-off-by: Harshavardhana <[email protected]>
1 parent 00dcba9 commit b6e98ae

17 files changed

+55
-26
lines changed

.github/workflows/multipart/migrate.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ if [ ! -f ./mc ]; then
2525
fi
2626

2727
(
28-
cd /tmp
29-
go install github.com/minio/minio/docs/debugging/s3-check-md5@master
28+
cd ./docs/debugging/s3-check-md5
29+
go install -v
3030
)
3131

3232
export RELEASE=RELEASE.2023-08-29T23-07-35Z

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ docker: build ## builds minio docker container
177177
@docker build -q --no-cache -t $(TAG) . -f Dockerfile
178178

179179
install-race: checks ## builds minio to $(PWD)
180-
@echo "Building minio binary to './minio'"
180+
@echo "Building minio binary with -race to './minio'"
181181
@GORACE=history_size=7 CGO_ENABLED=1 go build -tags kqueue -race -trimpath --ldflags "$(LDFLAGS)" -o $(PWD)/minio 1>/dev/null
182-
@echo "Installing minio binary to '$(GOPATH)/bin/minio'"
182+
@echo "Installing minio binary with -race to '$(GOPATH)/bin/minio'"
183183
@mkdir -p $(GOPATH)/bin && cp -f $(PWD)/minio $(GOPATH)/bin/minio
184184

185185
install: build ## builds minio and installs it to $GOPATH/bin.

buildscripts/rewrite-old-new.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ function verify_rewrite() {
8787
exit 1
8888
fi
8989

90-
go install github.com/minio/minio/docs/debugging/s3-check-md5@master
90+
(
91+
cd ./docs/debugging/s3-check-md5
92+
go install -v
93+
)
94+
9195
if ! s3-check-md5 \
9296
-debug \
9397
-versions \

cmd/background-newdisks-heal-ops.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ func initAutoHeal(ctx context.Context, objAPI ObjectLayer) {
353353

354354
func getLocalDisksToHeal() (disksToHeal Endpoints) {
355355
globalLocalDrivesMu.RLock()
356-
localDrives := globalLocalDrives
356+
localDrives := cloneDrives(globalLocalDrives)
357357
globalLocalDrivesMu.RUnlock()
358358
for _, disk := range localDrives {
359359
_, err := disk.GetDiskID()

cmd/bucket-replication.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -3393,7 +3393,7 @@ func (p *ReplicationPool) persistToDrive(ctx context.Context, v MRFReplicateEntr
33933393
}
33943394

33953395
globalLocalDrivesMu.RLock()
3396-
localDrives := globalLocalDrives
3396+
localDrives := cloneDrives(globalLocalDrives)
33973397
globalLocalDrivesMu.RUnlock()
33983398

33993399
for _, localDrive := range localDrives {
@@ -3460,7 +3460,7 @@ func (p *ReplicationPool) loadMRF() (mrfRec MRFReplicateEntries, err error) {
34603460
}
34613461

34623462
globalLocalDrivesMu.RLock()
3463-
localDrives := globalLocalDrives
3463+
localDrives := cloneDrives(globalLocalDrives)
34643464
globalLocalDrivesMu.RUnlock()
34653465

34663466
for _, localDrive := range localDrives {

cmd/metrics-resource.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ func collectDriveMetrics(m madmin.RealtimeMetrics) {
274274
}
275275

276276
globalLocalDrivesMu.RLock()
277-
localDrives := globalLocalDrives
277+
localDrives := cloneDrives(globalLocalDrives)
278278
globalLocalDrivesMu.RUnlock()
279279

280280
for _, d := range localDrives {

cmd/peer-rest-server.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ var errUnsupportedSignal = fmt.Errorf("unsupported signal")
786786

787787
func waitingDrivesNode() map[string]madmin.DiskMetrics {
788788
globalLocalDrivesMu.RLock()
789-
localDrives := globalLocalDrives
789+
localDrives := cloneDrives(globalLocalDrives)
790790
globalLocalDrivesMu.RUnlock()
791791

792792
errs := make([]error, len(localDrives))

cmd/peer-s3-server.go

+11-5
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func (s *peerS3Server) HealthHandler(w http.ResponseWriter, r *http.Request) {
8282

8383
func healBucketLocal(ctx context.Context, bucket string, opts madmin.HealOpts) (res madmin.HealResultItem, err error) {
8484
globalLocalDrivesMu.RLock()
85-
localDrives := globalLocalDrives
85+
localDrives := cloneDrives(globalLocalDrives)
8686
globalLocalDrivesMu.RUnlock()
8787

8888
// Initialize sync waitgroup.
@@ -206,7 +206,7 @@ func healBucketLocal(ctx context.Context, bucket string, opts madmin.HealOpts) (
206206

207207
func listBucketsLocal(ctx context.Context, opts BucketOptions) (buckets []BucketInfo, err error) {
208208
globalLocalDrivesMu.RLock()
209-
localDrives := globalLocalDrives
209+
localDrives := cloneDrives(globalLocalDrives)
210210
globalLocalDrivesMu.RUnlock()
211211

212212
quorum := (len(localDrives) / 2)
@@ -252,9 +252,15 @@ func listBucketsLocal(ctx context.Context, opts BucketOptions) (buckets []Bucket
252252
return buckets, nil
253253
}
254254

255+
func cloneDrives(drives []StorageAPI) []StorageAPI {
256+
newDrives := make([]StorageAPI, len(drives))
257+
copy(newDrives, drives)
258+
return newDrives
259+
}
260+
255261
func getBucketInfoLocal(ctx context.Context, bucket string, opts BucketOptions) (BucketInfo, error) {
256262
globalLocalDrivesMu.RLock()
257-
localDrives := globalLocalDrives
263+
localDrives := cloneDrives(globalLocalDrives)
258264
globalLocalDrivesMu.RUnlock()
259265

260266
g := errgroup.WithNErrs(len(localDrives)).WithConcurrency(32)
@@ -303,7 +309,7 @@ func getBucketInfoLocal(ctx context.Context, bucket string, opts BucketOptions)
303309

304310
func deleteBucketLocal(ctx context.Context, bucket string, opts DeleteBucketOptions) error {
305311
globalLocalDrivesMu.RLock()
306-
localDrives := globalLocalDrives
312+
localDrives := cloneDrives(globalLocalDrives)
307313
globalLocalDrivesMu.RUnlock()
308314

309315
g := errgroup.WithNErrs(len(localDrives)).WithConcurrency(32)
@@ -341,7 +347,7 @@ func deleteBucketLocal(ctx context.Context, bucket string, opts DeleteBucketOpti
341347

342348
func makeBucketLocal(ctx context.Context, bucket string, opts MakeBucketOptions) error {
343349
globalLocalDrivesMu.RLock()
344-
localDrives := globalLocalDrives
350+
localDrives := cloneDrives(globalLocalDrives)
345351
globalLocalDrivesMu.RUnlock()
346352

347353
g := errgroup.WithNErrs(len(localDrives)).WithConcurrency(32)

docs/bucket/replication/delete-replication.sh

+6-2
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,13 @@ echo "=== myminio1"
7575
echo "=== myminio2"
7676
./mc ls --versions myminio2/testbucket/dir/file
7777

78-
versionId="$(mc ls --json --versions myminio1/testbucket/dir/ | tail -n1 | jq -r .versionId)"
78+
versionId="$(./mc ls --json --versions myminio1/testbucket/dir/ | tail -n1 | jq -r .versionId)"
7979

80-
aws s3api --endpoint-url http://localhost:9001 --profile minio delete-object --bucket testbucket --key dir/file --version-id "$versionId"
80+
aws configure set aws_access_key_id minioadmin --profile minioadmin
81+
aws configure set aws_secret_access_key minioadmin --profile minioadmin
82+
aws configure set default.region us-east-1 --profile minioadmin
83+
84+
aws s3api --endpoint-url http://localhost:9001 --profile minioadmin delete-object --bucket testbucket --key dir/file --version-id "$versionId"
8185

8286
./mc ls -r --versions myminio1/testbucket >/tmp/myminio1.txt
8387
./mc ls -r --versions myminio2/testbucket >/tmp/myminio2.txt

docs/bucket/replication/setup_3site_replication.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ unset MINIO_KMS_KES_KEY_FILE
4141
unset MINIO_KMS_KES_ENDPOINT
4242
unset MINIO_KMS_KES_KEY_NAME
4343

44-
go install github.com/minio/minio/docs/debugging/s3-check-md5@latest
44+
(
45+
cd ./docs/debugging/s3-check-md5
46+
go install -v
47+
)
4548

4649
wget -O mc https://dl.minio.io/client/mc/release/linux-amd64/mc &&
4750
chmod +x mc

docs/debugging/s3-check-md5/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func main() {
163163
continue
164164
}
165165
if v, ok := object.UserMetadata["X-Amz-Server-Side-Encryption"]; ok && v == "aws:kms" {
166-
log.Println("FAILED: encrypted with SSE-KMS do not have md5sum as ETag:", objFullPath(object))
166+
log.Println("SKIPPED: encrypted with SSE-KMS do not have md5sum as ETag:", objFullPath(object))
167167
continue
168168
}
169169
parts := 1

docs/distributed/decom-compressed-sse-s3.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,10 @@ if [ $ret -ne 0 ]; then
147147
exit 1
148148
fi
149149

150-
go install github.com/minio/minio/docs/debugging/s3-check-md5@latest
150+
(
151+
cd ./docs/debugging/s3-check-md5
152+
go install -v
153+
)
151154

152155
s3-check-md5 -versions -access-key minioadmin -secret-key minioadmin -endpoint http://127.0.0.1:9001/ -bucket bucket2
153156
s3-check-md5 -versions -access-key minioadmin -secret-key minioadmin -endpoint http://127.0.0.1:9001/ -bucket versioned

docs/distributed/decom-encrypted-sse-s3.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,10 @@ if [ $ret -ne 0 ]; then
158158
exit 1
159159
fi
160160

161-
go install github.com/minio/minio/docs/debugging/s3-check-md5@latest
161+
(
162+
cd ./docs/debugging/s3-check-md5
163+
go install -v
164+
)
162165

163166
s3-check-md5 -versions -access-key minioadmin -secret-key minioadmin -endpoint http://127.0.0.1:9001/ -bucket bucket2
164167
s3-check-md5 -versions -access-key minioadmin -secret-key minioadmin -endpoint http://127.0.0.1:9001/ -bucket versioned

docs/distributed/decom-encrypted.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,10 @@ if [ "${expected_checksum}" != "${got_checksum}" ]; then
144144
exit 1
145145
fi
146146

147-
go install github.com/minio/minio/docs/debugging/s3-check-md5@latest
147+
(
148+
cd ./docs/debugging/s3-check-md5
149+
go install -v
150+
)
148151

149152
s3-check-md5 -versions -access-key minioadmin -secret-key minioadmin -endpoint http://127.0.0.1:9001/ -bucket bucket2
150153
s3-check-md5 -versions -access-key minioadmin -secret-key minioadmin -endpoint http://127.0.0.1:9001/ -bucket versioned

docs/distributed/decom.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,10 @@ if [ "${expected_checksum}" != "${got_checksum}" ]; then
210210
exit 1
211211
fi
212212

213-
go install github.com/minio/minio/docs/debugging/s3-check-md5@latest
213+
(
214+
cd ./docs/debugging/s3-check-md5
215+
go install -v
216+
)
214217

215218
s3-check-md5 -versions -access-key minioadmin -secret-key minioadmin -endpoint http://127.0.0.1:9001/ -bucket bucket2
216219
s3-check-md5 -versions -access-key minioadmin -secret-key minioadmin -endpoint http://127.0.0.1:9001/ -bucket versioned

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ require (
4545
github.com/lithammer/shortuuid/v4 v4.0.0
4646
github.com/miekg/dns v1.1.58
4747
github.com/minio/cli v1.24.2
48-
github.com/minio/console v0.45.1-0.20240213061721-ee4d7b9b6940
48+
github.com/minio/console v0.46.0
4949
github.com/minio/csvparser v1.0.0
5050
github.com/minio/dnscache v0.1.1
5151
github.com/minio/dperf v0.5.3

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,8 @@ github.com/minio/cli v1.24.2 h1:J+fCUh9mhPLjN3Lj/YhklXvxj8mnyE/D6FpFduXJ2jg=
432432
github.com/minio/cli v1.24.2/go.mod h1:bYxnK0uS629N3Bq+AOZZ+6lwF77Sodk4+UL9vNuXhOY=
433433
github.com/minio/colorjson v1.0.6 h1:m7TUvpvt0u7FBmVIEQNIa0T4NBQlxrcMBp4wJKsg2Ik=
434434
github.com/minio/colorjson v1.0.6/go.mod h1:LUXwS5ZGNb6Eh9f+t+3uJiowD3XsIWtsvTriUBeqgYs=
435-
github.com/minio/console v0.45.1-0.20240213061721-ee4d7b9b6940 h1:DdXAWKUmiSMFS3pPG351kwYo2YlC0EaKKCNStAmd7xo=
436-
github.com/minio/console v0.45.1-0.20240213061721-ee4d7b9b6940/go.mod h1:VvJdNfELVCc2VELF1rJtIPCb3FcWGtNfM/Ktvnu2MZ0=
435+
github.com/minio/console v0.46.0 h1:So7y3csQl7m3Llaxmbg5xiTCwlElUol8kUyVOViBRFY=
436+
github.com/minio/console v0.46.0/go.mod h1:VvJdNfELVCc2VELF1rJtIPCb3FcWGtNfM/Ktvnu2MZ0=
437437
github.com/minio/csvparser v1.0.0 h1:xJEHcYK8ZAjeW4hNV9Zu30u+/2o4UyPnYgyjWp8b7ZU=
438438
github.com/minio/csvparser v1.0.0/go.mod h1:lKXskSLzPgC5WQyzP7maKH7Sl1cqvANXo9YCto8zbtM=
439439
github.com/minio/dnscache v0.1.1 h1:AMYLqomzskpORiUA1ciN9k7bZT1oB3YZN4cEIi88W5o=

0 commit comments

Comments
 (0)