Skip to content

Commit

Permalink
[Fix][Broker] Fix race condition in OpAddEntry (apache#15233)
Browse files Browse the repository at this point in the history
(cherry picked from commit b083e9a)
  • Loading branch information
mattisonchao authored and nicoloboschi committed Apr 28, 2022
1 parent f44b933 commit db0b52c
Showing 1 changed file with 2 additions and 1 deletion.
Expand Up @@ -3810,12 +3810,13 @@ private void checkAddTimeout() {
}
OpAddEntry opAddEntry = pendingAddEntries.peek();
if (opAddEntry != null) {
final long finalAddOpCount = opAddEntry.addOpCount;
boolean isTimedOut = opAddEntry.lastInitTime != -1
&& TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - opAddEntry.lastInitTime) >= timeoutSec;
if (isTimedOut) {
log.error("Failed to add entry for ledger {} in time-out {} sec",
(opAddEntry.ledger != null ? opAddEntry.ledger.getId() : -1), timeoutSec);
opAddEntry.handleAddTimeoutFailure(opAddEntry.ledger, opAddEntry.addOpCount);
opAddEntry.handleAddTimeoutFailure(opAddEntry.ledger, finalAddOpCount);
}
}
}
Expand Down

0 comments on commit db0b52c

Please sign in to comment.