Comments (3)
I also find this logic as a bit odd: we don't check existing lock status on the first iteration and we may not pass this condition:
if (LockClientUtils.INSTANCE.millisecondTime() - currentTimeMillis > millisecondsToWait) {
throw new LockNotGrantedException("Didn't acquire lock after sleeping for " + (LockClientUtils.INSTANCE.millisecondTime() - currentTimeMillis) + " milliseconds");
}
To go to the Thread.sleep(refreshPeriodInMilliseconds);
and to the second iteration.
The millisecondsToWait
might be small enough and DynamoDB request might be long enough do not let us to overcome that condition.
Therefore it would be great to check an expiration status on existing lock even from the first iteration. We definitely might even not need extra iteration and that unnecessary sleep in between.
Also the current logic doesn't meet boolean tryLock(long time, TimeUnit unit) throws InterruptedException;
contract.
I may agree about some timeout approximation during request to the DB and back, but there is definitely no any reason for me to wait for the lock more than tryLock()
requests from me.
Originally I did a mistake like:
long timeToWaitForLock = System.currentTimeMillis() - start + TimeUnit.MILLISECONDS.convert(time, unit) - DynamoDbLockRegistry.this.leaseDuration;
this.acquireLockOptionsBuilder
.withAdditionalTimeToWaitForLock(timeToWaitForLock)
.withRefreshPeriod(0);
I'm really not interested to wait for the leaseDuration
(remember: tryLock()
contract ?), so i decided to minus it, but I missed the fact that you don't check status on the first iteration, therefore I failed to meet a condition for the second iteration.
Anyway, independently of my misinterpretation, there is that flaw, when we always fail with the condition because a millisecondsToWait
is so small in comparison with the request time, that we never know an existing lock state.
Thanks
from amazon-dynamodb-lock-client.
Yeah, I don't get this either. I wound up having to write my own locking library because this issue prevents usage in Lambda where the lease duration is a significant percentage of the Lambda timeout.
from amazon-dynamodb-lock-client.
@jazir1979 @artembilan @softwareengineerprogrammer This issue is related and may be identical to #12 . Stay tuned, there will be an update to #12 very soon.
from amazon-dynamodb-lock-client.
Related Issues (20)
- Separate blocking and non-blocking methods instead of using skipBlockingWait
- Will the latest release be pushed to Maven? HOT 1
- can client.acquireLock callback be made asynchronous?
- Getting this exception while app initialisation. Is this some known issue? HOT 1
- Upgrade to JDK17+ HOT 1
- Any port on the horizon to Python/Javascript?
- Documentation on inter-region locking
- Service: AmazonDynamoDBv2; Status Code: 400; Error Code: AccessDeniedException
- Is it possible to migrate this set of logic to a relational database, such as MySQL
- Interest in a TypeScript port? HOT 1
- Change License to ASLv2 or MIT
- amazon-dynamodb-lock-client as singleton
- Table cloudformation template
- [Feature Request] Soft Unlock
- withShouldSkipBlockingWait will always fail to acquire lock if already exists and expired HOT 7
- Potential Bug - Client should reset leaseDuration waiting time when recordVersionNumber noticed to change
- Failed to run demo code HOT 1
- Upgrade aws skd version
- Avoid `synchronized` during blocking operations (loom friendliness)
- Is this project dead?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amazon-dynamodb-lock-client.