Skip to content

Enhanced unlock() method of JdbcLock to verify successful unlocking #9291

Closed
@EddieChoCho

Description

@EddieChoCho

Expected Behavior

  • The unlock() method of JdbcLock should verify the execution result of releasing the lock ownership.
  • If the ownership can not be removed due to data expiration, a ConcurrentModificationException should be thrown.
  • The RedisLock implementation should also throw a ConcurrentModificationException in similar scenarios.

Current Behavior

  • The unlock() method does not verify the execution result of releasing the lock ownership.
  • The RedisLock throws an IllegalStateException when attempting to release the lock after the ownership has expired.

Context

If the unlock() method does not verify the execution result of releasing the lock ownership, users might face concurrency issues without being notified. For example:

  1. Process A and process B are operating in the same region. Process A acquires the distributed lock with lock_key: 'key'.
  2. Due to prolonged work, the ownership of the lock held by process A expires.
  3. Before process A releases the lock, process B also acquires the distributed lock with same lock_key.
  4. When process A attempts to release the distributed lock, the current implementation does not inform the user that the integrity of data protected by this lock may have been compromised.

To address this, it is proposed that the unlock() method be enhanced to verify if the ownership of lock has been removed successfully. If the ownership cannot be removed due to data expiration, a ConcurrentModificationException will be thrown. This approach maintains the integrity of the distributed lock mechanism.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions