diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java index 04270c72f53..ea5295dc7a8 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java @@ -1870,7 +1870,8 @@ void handleBookieFailure(final Map failedBookies) { LOG.debug("Ensemble change is disabled. Retry sending to failed bookies {} for ledger {}.", failedBookies, ledgerId); } - unsetSuccessAndSendWriteRequest(getCurrentEnsemble(), failedBookies.keySet()); + executeOrdered(() -> + unsetSuccessAndSendWriteRequest(getCurrentEnsemble(), failedBookies.keySet())); return; } diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/PendingAddOp.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/PendingAddOp.java index 8dc50370194..3a78696e886 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/PendingAddOp.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/PendingAddOp.java @@ -231,7 +231,7 @@ synchronized void unsetSuccessAndSendWriteRequest(List ensemble, int b /** * Initiate the add operation. */ - public void initiate() { + public synchronized void initiate() { hasRun = true; if (callbackTriggered) { // this should only be true if the request was failed due @@ -452,7 +452,7 @@ private PendingAddOp(Handle recyclerHandle) { } - private void maybeRecycle() { + private synchronized void maybeRecycle() { /** * We have opportunity to recycle two objects here. * PendingAddOp#toSend and LedgerHandle#pendingAddOp @@ -482,7 +482,7 @@ private void maybeRecycle() { } } - public void recyclePendAddOpObject() { + public synchronized void recyclePendAddOpObject() { entryId = LedgerHandle.INVALID_ENTRY_ID; currentLedgerLength = -1; if (payload != null) {