Skip to content

Fix stale pending-add ensembles and ACK invalidation ordering - #4924

Open
horizonzy wants to merge 1 commit into
apache:masterfrom
horizonzy:codex/fix-stale-ensemble-ack-order
Open

horizonzy wants to merge 1 commit into
apache:masterfrom
horizonzy:codex/fix-stale-ensemble-ack-order

Conversation

@horizonzy

Copy link
Copy Markdown
Member

Motivation

An add can capture an ensemble before it is queued and miss an ensemble-change resend pass. A later no-op change, or a change affecting only another index, does not retry its missing writes when resend indices are derived only from ledger metadata. The stranded entry blocks subsequent completion callbacks and LAC advancement.

Processing changed indices individually can also invoke completion callbacks for a write-set-external index before ACKs for other changed indices, or later pending entries, have been invalidated.

Changes

  • Reconcile each pending operation against the target ensemble, including changes it missed before enqueueing.
  • Prepare the entire pending queue before resending: invalidate affected ACKs and remove their bookies from the successful-bookie set used for fault-domain checks.
  • Resend after preparation and explicitly advance callbacks afterward, including entries whose write sets did not change.
  • Add regression coverage for no-op changes, unrelated-index changes, multi-index ACK invalidation, late success/failure responses, successive ensemble reconciliation, and failures queued during an actual metadata ensemble change.

Validation

mvn -pl bookkeeper-server -am -Dexec.skip=true -Dtest=PendingAddOpTest,LedgerHandleInlineReadTest -Dsurefire.failIfNoSpecifiedTests=false -DtestRetryCount=0 -Dspotbugs.skip test

All 12 selected tests passed on upstream master (7b66b5d).

Native build commands are skipped for this Java client change. Full-cluster and SpotBugs checks have not been run locally.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved ACK handling can report success and advance LAC despite violating fault-domain placement, inline resend callbacks can access cleared or recycled state, and the regression test misses the triggering order.

3 open issues
What changed in this PR

This PR updates the BookKeeper client’s ensemble-change handling to reconcile stale pending adds and invalidate affected acknowledgments before resending writes or advancing completion callbacks.

Changes:

  • Reconcile each pending add against the target ensemble.
  • Prepare the entire pending queue before resending, then explicitly advance callbacks.
  • Add regression tests for stale ensembles, acknowledgment cleanup, late responses, and queued failures.
File Description
bookkeeper-server/​src/​test/​java/​org/​apache/​bookkeeper/​client/​PendingAddOpTest.java Adds ensemble reconciliation and callback-ordering regression coverage.
bookkeeper-server/​src/​main/​java/​org/​apache/​bookkeeper/​client/​PendingAddOp.java Separates ensemble preparation from resending and removes affected successful bookies.
bookkeeper-server/​src/​main/​java/​org/​apache/​bookkeeper/​client/​LedgerHandle.java Coordinates queue-wide preparation, resends, and callback advancement.

Review effort: Balanced

Comment on lines +201 to +207
for (int index : resend) {
addEntrySuccessBookies.remove(previous.get(index));
if (!ackSet.removeBookieAndCheck(index)) {
completed = false;
}
}
return resend;
Comment on lines +214 to 216
for (int index : indices) {
sendWriteRequest(ensemble, index);
}
assertTrue(op.completed);
}
handle.changingEnsemble = false;
Set<Integer> changed = new LinkedHashSet<>(Arrays.asList(2, 0, 1));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants