From 41232ec455381faad732a7e6f531b4c97fb0ef7a Mon Sep 17 00:00:00 2001 From: Matteo Merli Date: Sat, 25 Feb 2023 11:20:47 -0800 Subject: [PATCH 1/3] Fixed locking of PendingAddOp --- .../java/org/apache/bookkeeper/client/PendingAddOp.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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) { From 2c3d5bf350966a4352251c1f74f94f5c19f547be Mon Sep 17 00:00:00 2001 From: Matteo Merli Date: Sat, 25 Feb 2023 14:35:35 -0800 Subject: [PATCH 2/3] Fixed stack overflow --- .../main/java/org/apache/bookkeeper/client/PendingAddOp.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 3a78696e886..48de798bb86 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 @@ -358,7 +358,7 @@ public synchronized void writeComplete(int rc, long ledgerId, long entryId, Book } else { LOG.warn("Failed to write entry ({}, {}) to bookie ({}, {}): {}", ledgerId, entryId, bookieIndex, addr, BKException.getMessage(rc)); - lh.handleBookieFailure(ImmutableMap.of(bookieIndex, addr)); + lh.executeOrdered(() -> lh.handleBookieFailure(ImmutableMap.of(bookieIndex, addr))); } return; } From 4d3b7cbf2b01a8aad84a80dff63b6ce3044723bf Mon Sep 17 00:00:00 2001 From: Matteo Merli Date: Sun, 26 Feb 2023 09:44:04 -0800 Subject: [PATCH 3/3] Fixed stack overflow in different point --- .../main/java/org/apache/bookkeeper/client/LedgerHandle.java | 3 ++- .../main/java/org/apache/bookkeeper/client/PendingAddOp.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) 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 48de798bb86..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 @@ -358,7 +358,7 @@ public synchronized void writeComplete(int rc, long ledgerId, long entryId, Book } else { LOG.warn("Failed to write entry ({}, {}) to bookie ({}, {}): {}", ledgerId, entryId, bookieIndex, addr, BKException.getMessage(rc)); - lh.executeOrdered(() -> lh.handleBookieFailure(ImmutableMap.of(bookieIndex, addr))); + lh.handleBookieFailure(ImmutableMap.of(bookieIndex, addr)); } return; }