You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
to acquire a lock. At this point, A holds the lock, B is waiting for A (waiting for A’s key to be deleted), and C is waiting for B. Both client B and client C are blocked in the waitDeletes method.
the key held by client C in the waiting queue will be automatically deleted when the lease expires. However, client C will still remain blocked in the waitDeletes method until B’s key is deleted. Only then will client C be able to detect, through the check
// make sure the session is not expired, and the owner key still exists.
gresp, werr:=client.Get(ctx, m.myKey)
ifwerr!=nil {
m.Unlock(client.Ctx())
returnwerr
}
iflen(gresp.Kvs) ==0 { // is the session key lost?
returnErrSessionExpired
}
in the Lock method, that its key has already been deleted, thus returning the ErrSessionExpired error.
To resolve this issue, we can Watch for the deletion events of both the key with a smaller revision and the key held by the current client. This way, we can return immediately when the session expires instead of waiting until all keys with smaller revisions have been deleted.
Why is this needed?
Resolve the situation described in the TODO and reduce unnecessary lock waiting.
The text was updated successfully, but these errors were encountered:
What would you like to be added?
As mentioned in the
concurrency/Mutex
TODO,etcd/client/v3/concurrency/mutex.go
Line 88 in 05d5753
Suppose three clients (A, B, and C) sequentially call the
Lock
methodetcd/client/v3/concurrency/mutex.go
Line 75 in 05d5753
waitDeletes
method.etcd/client/v3/concurrency/key.go
Line 49 in 05d5753
Orphan
method,etcd/client/v3/concurrency/session.go
Line 102 in 05d5753
waitDeletes
method until B’s key is deleted. Only then will client C be able to detect, through the checketcd/client/v3/concurrency/mutex.go
Lines 96 to 105 in 05d5753
Lock
method, that its key has already been deleted, thus returning theErrSessionExpired
error.To resolve this issue, we can
Watch
for the deletion events of both the key with a smaller revision and the key held by the current client. This way, we can return immediately when the session expires instead of waiting until all keys with smaller revisions have been deleted.Why is this needed?
Resolve the situation described in the TODO and reduce unnecessary lock waiting.
The text was updated successfully, but these errors were encountered: