fix: rename(tmp, tmp-old) is necessary

previous PR incorrectly changed rename() from
tmp to -> tmp/.trash/uuid, since it is self
referential - to clear this up make sure its
renamed to a separate folder and deleted
in background - just like before.
This commit is contained in:
Harshavardhana 2021-06-16 16:19:18 -07:00
parent 4669d19f2a
commit 180eabaa8e

View File

@ -72,16 +72,16 @@ var printEndpointError = func() func(Endpoint, error, bool) {
// Cleans up tmp directory of the local disk.
func formatErasureCleanupTmp(diskPath string) error {
// Need to move temporary objects left behind from previous run of minio
// server to a unique directory under `minioMetaTmpBucket/.trash` to clean
// server to a unique directory under `minioMetaTmpBucket-old` to clean
// up `minioMetaTmpBucket` for the current run.
//
// /disk1/.minio.sys/tmp/.trash/uuid
// /disk1/.minio.sys/tmp-old/
// |__ 33a58b40-aecc-4c9f-a22f-ff17bfa33b62
// |__ e870a2c1-d09c-450c-a69c-6eaa54a89b3e
//
// In this example, `33a58b40-aecc-4c9f-a22f-ff17bfa33b62` directory contains
// temporary objects from one of the previous runs of minio server.
tmpOld := pathJoin(diskPath, minioMetaTmpDeletedBucket, mustGetUUID())
tmpOld := pathJoin(diskPath, minioMetaTmpBucket+"-old", mustGetUUID())
if err := renameAll(pathJoin(diskPath, minioMetaTmpBucket),
tmpOld); err != nil && err != errFileNotFound {
logger.LogIf(GlobalContext, fmt.Errorf("unable to rename (%s -> %s) %w, drive may be faulty please investigate",
@ -94,9 +94,9 @@ func formatErasureCleanupTmp(diskPath string) error {
renameAllBucketMetacache(diskPath)
// Removal of tmp-old folder is backgrounded completely.
go removeAll(tmpOld)
go removeAll(pathJoin(diskPath, minioMetaTmpBucket+"-old"))
if err := mkdirAll(pathJoin(diskPath, minioMetaTmpBucket), 0777); err != nil {
if err := mkdirAll(pathJoin(diskPath, minioMetaTmpDeletedBucket), 0777); err != nil {
logger.LogIf(GlobalContext, fmt.Errorf("unable to create (%s) %w, drive may be faulty please investigate",
pathJoin(diskPath, minioMetaTmpBucket),
err))