Description
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
method
etcd/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 check etcd/client/v3/concurrency/mutex.go
Lines 96 to 105 in 05d5753
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.