From 74253e1ddcf51a7d59853b142a6bac2ddf37b8b3 Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Tue, 24 Oct 2023 08:15:41 -0700 Subject: [PATCH] Fix BackendInfo() race (#18305) `GetParityForSC` has a value receiver, so Config is copied before the lock is obtained. Make it pointer receiver. Fixes: ``` WARNING: DATA RACE Read at 0x0000079cdd10 by goroutine 190: github.com/minio/minio/cmd.(*erasureServerPools).BackendInfo() github.com/minio/minio/cmd/erasure-server-pool.go:579 +0x6f github.com/minio/minio/cmd.(*erasureServerPools).LocalStorageInfo() github.com/minio/minio/cmd/erasure-server-pool.go:614 +0x3c6 github.com/minio/minio/cmd.(*peerRESTServer).LocalStorageInfoHandler() github.com/minio/minio/cmd/peer-rest-server.go:347 +0x4ea github.com/minio/minio/cmd.(*peerRESTServer).LocalStorageInfoHandler-fm() ... WARNING: DATA RACE Read at 0x0000079cdd10 by goroutine 190: github.com/minio/minio/cmd.(*erasureServerPools).BackendInfo() github.com/minio/minio/cmd/erasure-server-pool.go:579 +0x6f github.com/minio/minio/cmd.(*erasureServerPools).LocalStorageInfo() github.com/minio/minio/cmd/erasure-server-pool.go:614 +0x3c6 github.com/minio/minio/cmd.(*peerRESTServer).LocalStorageInfoHandler() github.com/minio/minio/cmd/peer-rest-server.go:347 +0x4ea github.com/minio/minio/cmd.(*peerRESTServer).LocalStorageInfoHandler-fm() ``` --- internal/config/storageclass/storage-class.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/config/storageclass/storage-class.go b/internal/config/storageclass/storage-class.go index 5f8f4246c..15580a6aa 100644 --- a/internal/config/storageclass/storage-class.go +++ b/internal/config/storageclass/storage-class.go @@ -228,7 +228,7 @@ func validateParity(ssParity, rrsParity, setDriveCount int) (err error) { // // is returned, the caller is expected to choose the right parity // at that point. -func (sCfg Config) GetParityForSC(sc string) (parity int) { +func (sCfg *Config) GetParityForSC(sc string) (parity int) { ConfigLock.RLock() defer ConfigLock.RUnlock() switch strings.TrimSpace(sc) {