mirror of
https://github.com/minio/minio.git
synced 2025-02-23 11:32:32 -05:00
erasure: healVolume err should be different from shadowed version. (#1590)
Multiple go-routines updating the same shadowed variable can cause a data race, avoid it by using its own err variable. Fixes #1589
This commit is contained in:
parent
49141eb3e4
commit
72748d2073
@ -51,11 +51,11 @@ func (xl XL) ReadFile(volume, path string, startOffset int64) (io.ReadCloser, er
|
|||||||
// Heal in background safely, since we already have read
|
// Heal in background safely, since we already have read
|
||||||
// quorum disks. Let the reads continue.
|
// quorum disks. Let the reads continue.
|
||||||
go func() {
|
go func() {
|
||||||
if err = xl.healFile(volume, path); err != nil {
|
if hErr := xl.healFile(volume, path); hErr != nil {
|
||||||
log.WithFields(logrus.Fields{
|
log.WithFields(logrus.Fields{
|
||||||
"volume": volume,
|
"volume": volume,
|
||||||
"path": path,
|
"path": path,
|
||||||
}).Errorf("healFile failed with %s", err)
|
}).Errorf("healFile failed with %s", hErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -311,6 +311,10 @@ func (xl XL) listAllVolumeInfo(volume string) ([]VolInfo, bool, error) {
|
|||||||
|
|
||||||
// healVolume - heals any missing volumes.
|
// healVolume - heals any missing volumes.
|
||||||
func (xl XL) healVolume(volume string) error {
|
func (xl XL) healVolume(volume string) error {
|
||||||
|
// Acquire a read lock.
|
||||||
|
nsMutex.RLock(volume, "")
|
||||||
|
defer nsMutex.RUnlock(volume, "")
|
||||||
|
|
||||||
// Lists volume info for all online disks.
|
// Lists volume info for all online disks.
|
||||||
volsInfo, heal, err := xl.listAllVolumeInfo(volume)
|
volsInfo, heal, err := xl.listAllVolumeInfo(volume)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -345,7 +349,9 @@ func (xl XL) StatVol(volume string) (volInfo VolInfo, err error) {
|
|||||||
if !isValidVolname(volume) {
|
if !isValidVolname(volume) {
|
||||||
return VolInfo{}, errInvalidArgument
|
return VolInfo{}, errInvalidArgument
|
||||||
}
|
}
|
||||||
|
nsMutex.RLock(volume, "")
|
||||||
volsInfo, heal, err := xl.listAllVolumeInfo(volume)
|
volsInfo, heal, err := xl.listAllVolumeInfo(volume)
|
||||||
|
nsMutex.RUnlock(volume, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithFields(logrus.Fields{
|
log.WithFields(logrus.Fields{
|
||||||
"volume": volume,
|
"volume": volume,
|
||||||
@ -355,10 +361,10 @@ func (xl XL) StatVol(volume string) (volInfo VolInfo, err error) {
|
|||||||
|
|
||||||
if heal {
|
if heal {
|
||||||
go func() {
|
go func() {
|
||||||
if err = xl.healVolume(volume); err != nil {
|
if herr := xl.healVolume(volume); herr != nil {
|
||||||
log.WithFields(logrus.Fields{
|
log.WithFields(logrus.Fields{
|
||||||
"volume": volume,
|
"volume": volume,
|
||||||
}).Errorf("healVolume failed with %s", err)
|
}).Errorf("healVolume failed with %s", herr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@ -436,11 +442,11 @@ func (xl XL) StatFile(volume, path string) (FileInfo, error) {
|
|||||||
if heal {
|
if heal {
|
||||||
// Heal in background safely, since we already have read quorum disks.
|
// Heal in background safely, since we already have read quorum disks.
|
||||||
go func() {
|
go func() {
|
||||||
if err = xl.healFile(volume, path); err != nil {
|
if hErr := xl.healFile(volume, path); hErr != nil {
|
||||||
log.WithFields(logrus.Fields{
|
log.WithFields(logrus.Fields{
|
||||||
"volume": volume,
|
"volume": volume,
|
||||||
"path": path,
|
"path": path,
|
||||||
}).Errorf("healFile failed with %s", err)
|
}).Errorf("healFile failed with %s", hErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user