fix: assign PUT generations while holding the commit lock

Signed-off-by: Feng Ruohang <rh@vonng.com>
This commit is contained in:
Feng Ruohang
2026-10-25 01:08:36 +08:00
parent 5c074efd1d
commit d2eb0ade91
2 changed files with 114 additions and 10 deletions
+12 -10
View File
@@ -1562,6 +1562,18 @@ func (er erasureObjects) putObject(ctx context.Context, bucket string, object st
compIndex = opts.IndexCB()
}
if !opts.NoLock {
lk := er.NewNSLock(bucket, object)
lkctx, err := lk.GetLock(ctx, globalOperationTimeout)
if err != nil {
return ObjectInfo{}, err
}
ctx = lkctx.Context()
defer lk.Unlock(lkctx)
}
// Mint the generation while holding the commit lock. Staged uploads may
// acquire the lock in a different order from their encoding completion.
modTime := opts.MTime
if opts.MTime.IsZero() {
modTime = UTCNow()
@@ -1658,16 +1670,6 @@ func (er erasureObjects) putObject(ctx context.Context, bucket string, object st
}
}
if !opts.NoLock {
lk := er.NewNSLock(bucket, object)
lkctx, err := lk.GetLock(ctx, globalOperationTimeout)
if err != nil {
return ObjectInfo{}, err
}
ctx = lkctx.Context()
defer lk.Unlock(lkctx)
}
if !opts.ReplicationRequest && !opts.ReplicaLockReconcile && !opts.DataMovement &&
(fi.VersionID == "" || fi.VersionID == nullVersionID) {
getObjectInfo := er.getObjectInfo