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
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: