mirror of
https://github.com/minio/minio.git
synced 2025-01-25 21:53:16 -05:00
Fix RenameData data race (#19579)
RenameData could start operating on inline data after timing out and the call returned due to WithDeadline. This could cause a buffer to write to the inline data being written. Since no writes are in `RenameData` and the call is canceled, this doesn't present a corruption issue. But a race is a race and should be fixed. Copy inline data to a fresh buffer.
This commit is contained in:
parent
95c65f4e8f
commit
b5a09ff96b
@ -32,6 +32,7 @@ import (
|
||||
|
||||
"github.com/minio/madmin-go/v3"
|
||||
"github.com/minio/minio/internal/cachevalue"
|
||||
"github.com/minio/minio/internal/grid"
|
||||
xioutil "github.com/minio/minio/internal/ioutil"
|
||||
"github.com/minio/minio/internal/logger"
|
||||
)
|
||||
@ -471,8 +472,14 @@ func (p *xlStorageDiskIDCheck) RenameData(ctx context.Context, srcVolume, srcPat
|
||||
}
|
||||
done(&err)
|
||||
}()
|
||||
|
||||
// Copy inline data to a new buffer to function with deadlines.
|
||||
if len(fi.Data) > 0 {
|
||||
fi.Data = append(grid.GetByteBufferCap(len(fi.Data))[:0], fi.Data...)
|
||||
}
|
||||
return xioutil.WithDeadline[uint64](ctx, globalDriveConfig.GetMaxTimeout(), func(ctx context.Context) (result uint64, err error) {
|
||||
if len(fi.Data) > 0 {
|
||||
defer grid.PutByteBuffer(fi.Data)
|
||||
}
|
||||
return p.storage.RenameData(ctx, srcVolume, srcPath, fi, dstVolume, dstPath, opts)
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user