Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expiry_period does not expire locks #2793

Open
malcolmtank opened this issue Aug 15, 2024 · 0 comments
Open

expiry_period does not expire locks #2793

malcolmtank opened this issue Aug 15, 2024 · 0 comments

Comments

@malcolmtank
Copy link

malcolmtank commented Aug 15, 2024

  • Python DynamoDB Lock version: 0.9.1
  • Python version: 3.12
  • Operating System: Linux and MacOS

Description

I'm trying to auto-delete locks after server crashes. To accomplish this, I set a relatively short expiry_period.
After crashes, long after the expiry_time reported by dynamodb, I still see lock acquisition timeouts.

What I Did

I have tried to acquire expired locks and observed lock acquisition timeouts. I would like to make a change like the following to acquire_lock:

# if the record_version_number has not changed for more than _lease_duration period,
# it basically means that the owner thread/process has died.
now = time.monotonic()
last_version_elapsed_time = now - last_version_fetch_time
if last_version_elapsed_time > existing_lock.lease_duration or now > existing_lock.expiry_time:  # key change here
    logger.warning('Existing lock\'s lease has expired: %s', str(existing_lock))
    self._overwrite_existing_lock_in_dynamodb(new_lock, last_record_version_number)
    logger.debug('Added to the DDB. Adding to in-memory map: %s', new_lock.unique_identifier)
    new_lock.status = DynamoDBLock.LOCKED
    self._locks[new_lock.unique_identifier] = new_lock
    logger.info('Successfully updated with the new lock: %s', str(new_lock))
    return new_lock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant