awslabs / amazon-dynamodb-lock-client

The AmazonDynamoDBLockClient is a general purpose distributed locking library built on top of DynamoDB. It supports both coarse-grained and fine-grained locking.
Other
472 stars 85 forks source link

Sync local lockItem with dynamodb after `sendHeartbeat(options)` changes the data #55

Closed lcabancla closed 3 years ago

lcabancla commented 3 years ago

Issue #, if available: https://github.com/awslabs/amazon-dynamodb-lock-client/issues/54

Description of changes:

Make LockItem's data field an AtomicReference so that a new method updateData() can update it. If sendHeartbeat(options) successfully updates or removes the data in dynamodb, the lockItem's updateData() method is called to sync the data with dynamodb.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

lcabancla commented 3 years ago

@KasulaVamsi Thanks for the approval. What's the process for merging these to master and publishing the changes? I don't have write access to merge.

lcabancla commented 3 years ago

I also noticed that the source code version is 1.2.0 which is unreleased. Is it possible to have this fix and this included into the 1.1 branch?

lcabancla commented 3 years ago

@kapilsingh5050 We don't need to reset data there since the only reason why the rvn is being reset with lastUpdateOfLock=0 is to indicate that the lock has expired. If the lock has expired, the client no longer owns the lock, hence there is no need for updated data.