Skip to content

Commit 4a4d1b2

Browse files
author
graysonzeng
committed
fix_topic_unavailable_error
1 parent f88f437 commit 4a4d1b2

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ private enum HandleState {
146146

147147
ScheduledFuture<?> timeoutFuture = null;
148148

149+
private AtomicBoolean sendingCallbacks = new AtomicBoolean(false);
150+
149151
@VisibleForTesting
150152
final Map<Integer, BookieId> delayedWriteFailedBookies =
151153
new HashMap<Integer, BookieId>();
@@ -1811,12 +1813,17 @@ void sendAddSuccessCallbacks() {
18111813
// entries that have had all their responses come back
18121814
PendingAddOp pendingAddOp;
18131815

1816+
if (!sendingCallbacks.compareAndSet(false, true)) {
1817+
return;
1818+
}
1819+
18141820
while ((pendingAddOp = pendingAddOps.peek()) != null
18151821
&& !changingEnsemble) {
18161822
if (!pendingAddOp.completed) {
18171823
if (LOG.isDebugEnabled()) {
18181824
LOG.debug("pending add not completed: {}", pendingAddOp);
18191825
}
1826+
sendingCallbacks.set(false);
18201827
return;
18211828
}
18221829
// Check if it is the next entry in the sequence.
@@ -1825,6 +1832,7 @@ void sendAddSuccessCallbacks() {
18251832
LOG.debug("Head of the queue entryId: {} is not the expected value: {}", pendingAddOp.entryId,
18261833
pendingAddsSequenceHead + 1);
18271834
}
1835+
sendingCallbacks.set(false);
18281836
return;
18291837
}
18301838

@@ -1838,6 +1846,7 @@ void sendAddSuccessCallbacks() {
18381846
pendingAddOp.submitCallback(BKException.Code.OK);
18391847
}
18401848

1849+
sendingCallbacks.set(false);
18411850
}
18421851

18431852
@VisibleForTesting

0 commit comments

Comments
 (0)