mirror of
https://github.com/minio/minio.git
synced 2025-01-11 23:13:23 -05:00
fix: release locks if the client timedout (#11030)
situations where client indeed timedout there was a potential to falsely think that lock is still active.
This commit is contained in:
parent
a896125490
commit
ee2a436a5b
@ -215,7 +215,7 @@ func lock(ctx context.Context, ds *Dsync, locks *[]string, id, source string, is
|
|||||||
ch := make(chan Granted, len(restClnts))
|
ch := make(chan Granted, len(restClnts))
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
|
|
||||||
// Combined timout for the lock attempt.
|
// Combined timeout for the lock attempt.
|
||||||
ctx, cancel := context.WithTimeout(ctx, DRWMutexAcquireTimeout)
|
ctx, cancel := context.WithTimeout(ctx, DRWMutexAcquireTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
for index, c := range restClnts {
|
for index, c := range restClnts {
|
||||||
@ -282,8 +282,13 @@ func lock(ctx context.Context, ds *Dsync, locks *[]string, id, source string, is
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
|
// Capture timedout locks as failed or took too long
|
||||||
|
locksFailed++
|
||||||
|
if locksFailed > tolerance {
|
||||||
|
// We know that we are not going to get the lock anymore,
|
||||||
|
// so exit out and release any locks that did get acquired
|
||||||
done = true
|
done = true
|
||||||
log("Timeout\n")
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if done {
|
if done {
|
||||||
@ -291,10 +296,9 @@ func lock(ctx context.Context, ds *Dsync, locks *[]string, id, source string, is
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Count locks in order to determine whether we have quorum or not
|
|
||||||
quorumLocked := checkQuorumLocked(locks, quorum) && locksFailed <= tolerance
|
quorumLocked := checkQuorumLocked(locks, quorum) && locksFailed <= tolerance
|
||||||
if !quorumLocked {
|
if !quorumLocked {
|
||||||
log("Quorum not met\n")
|
log("Releasing all acquired locks now abandoned after quorum was not met\n")
|
||||||
releaseAll(ds, tolerance, owner, locks, isReadLock, restClnts, lockNames...)
|
releaseAll(ds, tolerance, owner, locks, isReadLock, restClnts, lockNames...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user