mirror of
https://github.com/minio/minio.git
synced 2024-12-24 22:25:54 -05:00
fs: Fix setting new deployment ID in format when not present (#8517)
The code does not properly set a new deployemnt ID when not present in format.json: it loops twice without releasing write lock on format.json causing an infinite locking error on the same file. This commit fixes and simplifies a little the code.
This commit is contained in:
parent
e9b2bf00ad
commit
60690a7e1d
@ -350,27 +350,24 @@ func formatFSFixDeploymentID(fsFormatPath string) error {
|
|||||||
logger.Info("Another minio process(es) might be holding a lock to the file %s. Please kill that minio process(es) (elapsed %s)\n", fsFormatPath, getElapsedTime())
|
logger.Info("Another minio process(es) might be holding a lock to the file %s. Please kill that minio process(es) (elapsed %s)\n", fsFormatPath, getElapsedTime())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err != nil {
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
defer wlk.Close()
|
||||||
|
|
||||||
if err = jsonLoad(wlk, format); err != nil {
|
if err = jsonLoad(wlk, format); err != nil {
|
||||||
break
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if format needs to be updated
|
// Check if format needs to be updated
|
||||||
if format.ID != "" {
|
if format.ID != "" {
|
||||||
err = nil
|
return nil
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set new UUID to the format and save it
|
||||||
format.ID = mustGetUUID()
|
format.ID = mustGetUUID()
|
||||||
if err = jsonSave(wlk, format); err != nil {
|
return jsonSave(wlk, format)
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if wlk != nil {
|
|
||||||
wlk.Close()
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user