-
Notifications
You must be signed in to change notification settings - Fork 123
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
Fix generated transaction IDs are not unique issue. #1587
Conversation
Signed-off-by: Nikita Lebedev <[email protected]>
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## develop #1587 +/- ##
=============================================
+ Coverage 82.11% 82.20% +0.08%
- Complexity 3569 3585 +16
=============================================
Files 186 186
Lines 11675 11692 +17
Branches 1146 1148 +2
=============================================
+ Hits 9587 9611 +24
+ Misses 1611 1603 -8
- Partials 477 478 +1
☔ View full report in Codecov by Sentry. |
do { | ||
currentTime = System.currentTimeMillis() * 1_000_000L; | ||
lastTime = monotonicTime.get(); | ||
if (currentTime <= lastTime) currentTime = lastTime + 1000L; | ||
} | ||
|
||
while (!monotonicTime.compareAndSet(lastTime, currentTime)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a comment here and maybe extract the consts for more code clarity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rokn please check it now :)
Signed-off-by: Nikita Lebedev <[email protected]>
Kudos, SonarCloud Quality Gate passed! |
@@ -64,6 +63,13 @@ public final class TransactionId implements Comparable<TransactionId> { | |||
@Nullable | |||
private Integer nonce = null; | |||
|
|||
private static final long MICROSECONDS_PER_MILLISECOND = 1_000_000L; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name is not right, should be NANOSECONDS_PER_MILLISECOND
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check #1605
@@ -64,6 +63,13 @@ public final class TransactionId implements Comparable<TransactionId> { | |||
@Nullable | |||
private Integer nonce = null; | |||
|
|||
private static final long MICROSECONDS_PER_MILLISECOND = 1_000_000L; | |||
|
|||
private static final long CLOCK_DRIFT_THRESHOLD = 1_000L; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clock drift but rather minimal timestamp increment in nanoseconds. Note that it allows for up to 1M TPS, which is assumed plenty for one client process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check #1605
Description:
Fix generated transaction IDs are not unique issue.
Related issue(s):
Fixes #1557
Checklist