Skip to content

Commit b083e9a

Browse files
authored
[Fix][Broker] Fix race condition in OpAddEntry (#15233)
1 parent 06ba587 commit b083e9a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3829,12 +3829,13 @@ private void checkAddTimeout() {
38293829
}
38303830
OpAddEntry opAddEntry = pendingAddEntries.peek();
38313831
if (opAddEntry != null) {
3832+
final long finalAddOpCount = opAddEntry.addOpCount;
38323833
boolean isTimedOut = opAddEntry.lastInitTime != -1
38333834
&& TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - opAddEntry.lastInitTime) >= timeoutSec;
38343835
if (isTimedOut) {
38353836
log.error("Failed to add entry for ledger {} in time-out {} sec",
38363837
(opAddEntry.ledger != null ? opAddEntry.ledger.getId() : -1), timeoutSec);
3837-
opAddEntry.handleAddTimeoutFailure(opAddEntry.ledger, opAddEntry.addOpCount);
3838+
opAddEntry.handleAddTimeoutFailure(opAddEntry.ledger, finalAddOpCount);
38383839
}
38393840
}
38403841
}

0 commit comments

Comments
 (0)