-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[pulsar-ml] handle race condition between timeout-task and add-call complete #4455
Conversation
rerun java8 tests |
@@ -3080,12 +3080,11 @@ private void checkAddTimeout() { | |||
OpAddEntry opAddEntry = pendingAddEntries.peek(); | |||
if (opAddEntry != null) { | |||
boolean isTimedOut = opAddEntry.lastInitTime != -1 | |||
&& TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - opAddEntry.lastInitTime) >= timeoutSec | |||
&& opAddEntry.completed == FALSE; | |||
&& TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - opAddEntry.lastInitTime) >= timeoutSec; |
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.
Don't understand why we removed opAddEntry.completed == FALSE
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.
we need atomic callback handler and want to make sure that OpAddEntry
callback completes atomically. So, we replaced boolean completed
with addOpCount
so, we can update it atomically and only one thread (bk-client/timeout-task) succeed to process the callback.
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 you add a little more description on how you solve the issue specially on why we changed AtomicIntegerFieldUpdater
.
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/OpAddEntry.java
Outdated
Show resolved
Hide resolved
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/OpAddEntry.java
Outdated
Show resolved
Hide resolved
rerun java8 tests |
rerun java8 tests |
@jai1 can you review it again? |
…completion - solution was added in apache#4455
…completion (apache#10740) - solution was added in apache#4455
…completion (apache#10740) - solution was added in apache#4455
…completion (apache#10740) - solution was added in apache#4455 (cherry picked from commit 4372b49)
…completion (apache#10740) - solution was added in apache#4455
…completion (apache#10740) - solution was added in apache#4455
Motivation
Broker has addEntry operation-timeout task which can timeout Add-entry operation if it's not completed in configured time. So, addEntry operation can be completed by timeout-task or normal bk-client thread. This PR makes sure that addEntry task can be completed atomically by one thread only.