feat(ha-convergence-recovery): ACK-driven catch-up continuation + parity re-inclusion (task 4.2)

This commit is contained in:
Rongsong Shen 2026-06-14 05:45:20 +00:00
parent c2221077ff
commit ffd08c6472
5 changed files with 243 additions and 22 deletions

View file

@ -377,30 +377,21 @@ void cluster_apply_ctrlhello_reply(cluster_t *c, uint64_t committed_lsn,
#ifdef XCE_TESTING
/* ───────────────────────────────────────────────────────────────────────────
* RED scaffold — ha-convergence-recovery task 4.1 (replaced by task 4.2 GREEN).
* ha_walack_continuation_for_test — task 4.2 GREEN.
*
* ha_walack_continuation_for_test stands in for the post-ACK decision that the
* walAck branch of repl_ack_decode_and_dispatch (ha.c) must perform after
* repl_on_ack (D6): derive target = max(committed_lsn, last_written); when the
* standby is still behind target, schedule exactly one catch-up continuation
* (single-flight via ha.catchup_inflight[peer_idx]); at/above target call
* repl_complete_catchup to re-include the standby (Req 7.1).
*
* THIS SCAFFOLD INTENTIONALLY DOES NOTHING beyond recording that the ACK was
* observed (it mirrors the current production walAck branch, which only calls
* repl_on_ack). It does NOT schedule a continuation and does NOT call
* repl_complete_catchup — so the continuation / single-flight / parity tests in
* test_convergence_verification.c FAIL (RED) until task 4.2 implements the real
* decision here and wires it into the production walAck branch.
* Test-only shim onto the REAL post-ACK catch-up decision ha_walack_on_ack
* (config_repl.c, D6). The production walAck branch of
* repl_ack_decode_and_dispatch (ha.c) calls the SAME ha_walack_on_ack after
* repl_on_ack, so production and the unit tests exercise identical logic
* (derive target = max(committed_lsn, last_written); behind target → schedule
* one single-flight continuation; at parity → repl_complete_catchup, Req
* 5.1/5.2/7.1). This shim exists only because the production caller decodes a
* real Cap'n Proto WalAckReply off the wire, which is too heavy to drive from a
* unit fixture.
* ─────────────────────────────────────────────────────────────────────────── */
int ha_walack_continuation_for_test(cluster_t *c, void *ep, int peer_idx,
uint64_t acked_lsn)
{
/* RED scaffold — task 4.2 replaces this body with the D6 decision. */
(void)c;
(void)ep;
(void)peer_idx;
(void)acked_lsn;
return 0;
return ha_walack_on_ack(c, ep, peer_idx, acked_lsn);
}
#endif /* XCE_TESTING */