wizory / llock

Laravel Lock (shared locking plugin)
1 stars 1 forks source link

locking appears to be non-atomic in some cases #1

Open jguice opened 7 years ago

jguice commented 7 years ago

e.g.

Aug 24 19:45:02 web0 _laravel:  production.DEBUG: Attempting to set lock foo []
Aug 24 19:45:02 web1 _laravel:  production.DEBUG: Attempting to set lock foo []
Aug 24 19:45:02 web1 _laravel:  production.DEBUG: Lock created successfully []
Aug 24 19:45:03 web0 _laravel:  production.DEBUG: Lock created successfully []

Two simultaneous locks from two different servers were obtained. Upon freeing the locks, only one was freed though resulting in a "stuck lock".

jguice commented 7 years ago

9e18bd3c03d7d17fd9de342beddd1741792c66ba attempts to fix this...testing pending.

jguice commented 6 years ago

Still happens periodically:

Jun 26 02:53:05 web1 _laravel: production.DEBUG: Lock created successfully []
Jun 26 02:53:05 web0 _laravel: production.DEBUG: Lock created successfully []
jguice commented 6 years ago

Reference materials: https://laravel.com/docs/5.1/queries#pessimistic-locking https://laracasts.com/discuss/channels/general-discussion/how-properly-use-the-lockforupdate-method https://medium.com/@gyani/avoid-race-condition-using-lockforupdate-function-and-mysql-transactions-1eaf473afd96

jguice commented 6 years ago

https://github.com/wizory/llock/pull/3 attempts to fix this...again