Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 4200: fix flaky test DeferredSyncTest.testForceWillAdvanceLacOnlyUpToLastAcknoledgedWrite #4234

Merged
merged 2 commits into from
Mar 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,15 @@ protected void suspendBookieForceLedgerAcks(BookieId address) {
}

protected void resumeBookieWriteAcks(BookieId address) {
suspendedBookiesForForceLedgerAcks.remove(address);
List<Runnable> pendingResponses = deferredBookieForceLedgerResponses.remove(address);
List<Runnable> pendingResponses;

// why use the BookieId instance as the object monitor? there is a date race problem if not
// see https://github.com/apache/bookkeeper/issues/4200
synchronized (address) {
tmzk1005 marked this conversation as resolved.
Show resolved Hide resolved
suspendedBookiesForForceLedgerAcks.remove(address);
pendingResponses = deferredBookieForceLedgerResponses.remove(address);
}

if (pendingResponses != null) {
pendingResponses.forEach(Runnable::run);
}
Expand Down Expand Up @@ -656,11 +663,17 @@ protected void setupBookieClientForceLedger() {
callback.forceLedgerComplete(BKException.Code.OK, ledgerId, bookieSocketAddress, ctx);
});
};
if (suspendedBookiesForForceLedgerAcks.contains(bookieSocketAddress)) {
List<Runnable> queue = deferredBookieForceLedgerResponses.computeIfAbsent(bookieSocketAddress,
(k) -> new CopyOnWriteArrayList<>());
queue.add(activity);
} else {
List<Runnable> queue = null;

synchronized (bookieSocketAddress) {
if (suspendedBookiesForForceLedgerAcks.contains(bookieSocketAddress)) {
queue = deferredBookieForceLedgerResponses.computeIfAbsent(bookieSocketAddress,
(k) -> new CopyOnWriteArrayList<>());
queue.add(activity);
}
}

if (queue == null) {
activity.run();
}
return null;
Expand Down
Loading