feat(ha-config-bootstrap): implement OP_ctrlHello state sync handler (task 9.3)

This commit is contained in:
Rongsong Shen 2026-05-29 05:22:17 +00:00
parent 0ec0ffa7e3
commit 94bf5d94b8
9 changed files with 396 additions and 3 deletions

View file

@ -123,6 +123,19 @@ int push_config_to_standbys(cluster_t *c, const uint8_t *bytes, size_t blen,
int handle_upgrade_config(cluster_t *c, endpoint_t *ep, xce_request_t *req,
const uint8_t *raw_pkt, size_t raw_pkt_sz);
/*
* handle_ctrlhello: primary-side handler for OP_hello from a joining standby.
*
* Implements the state sync sequence (Req 6.5, 6.6, 6.7):
* 1. repl_add_standby() + repl_start_catchup()
* 2. Reply CtrlHelloReply{committed_lsn, needs_snapshot, config_tag}
* 3. If needs_snapshot: persist_checkpoint() + stream OP_snapshotTransfer
* 4. Stream OP_walCatchupEntry [applied_lsn+1 → committed_lsn]
* 5. On catch-up complete: repl_complete_catchup()
* 6. If config_tag mismatch: push_config_to_standbys()
*/
int handle_ctrlhello(cluster_t *c, endpoint_t *ep, xce_request_t *req);
/*
* sanitise_cn: copy at most maxlen printable ASCII chars from src to a
* static buffer, replacing non-printable/control chars with '?'.