werf / lockgate

Lockgate is a cross-platform distributed locking library for Go. Supports distributed locks backed by Kubernetes or HTTP lock server. Supports conventional OS file locks.
Apache License 2.0
256 stars 15 forks source link

Fix kubernetes locker hanging when there are many 'optimistic locking' conflicts #24

Closed distorhead closed 4 years ago

distorhead commented 4 years ago

The hanging was due to double locking of mutex (classic) in some situation when sending a signal to the channel. The channel is unbuffered (zero capacity), which caused blocking when sending a done-chan signal. Due to blocking on the channel send mutex remained locked. Lockgate now will release mutex first, before sending a signal to this done-chan.

Also: