bsm / redislock

Simplified distributed locking implementation using Redis
Other
1.45k stars 157 forks source link

lock.Release() unable to release lock. #65

Closed divya-inaza closed 1 year ago

divya-inaza commented 1 year ago

The lock timeout becomes 0 after the set operation. That's why the lock.Release(ctx) throwing LockNotHeld error.

Attached is the value of lock timeout at various places...

  1. 24.9s after obtain()
  2. 24.899s after lock.TTL()
  3. 0s just after set()
  4. 0s just before lock.Release(ctx)

image

dim commented 1 year ago

Sorry, I am not sure I'm following. Are you using the latest version? We recently had a fix for timeout being reset https://github.com/bsm/redislock/blob/main/CHANGELOG.md#v091. Would you mind sharing some code?

divya-inaza commented 1 year ago

I am using v0.9.1.

Added the code snippet & the o/p of print statements

image

image

dim commented 1 year ago

Yes, if you change the value of the lock key, the lock is invalidated, hence you cannot release it anymore.