feat(ha-repl-hardening): primary snapshot chunk sender (task 3.5a)

ha_send_snapshot_to_standby reads snapshot file, splits into 64KB
chunks, sends each via OPCode_snapshotTransfer with correct metadata
(snapshotLsn, chunkIndex, chunkOffset, totalSize, isLast). Payload
encoding deferred. Hook seam for unit testing.
2 tests: 128KB/2-chunks, small-file/1-chunk. Tasks 3.5b-3.5d remain.
This commit is contained in:
Rongsong Shen 2026-06-05 01:16:34 +00:00
parent 6b69a47c50
commit 834ab4d5e7
5 changed files with 241 additions and 11 deletions

View file

@ -1075,10 +1075,19 @@ int ha_dispatch_repl_action_for_standby(ha_state_t *ha,
break;
case HA_REPL_SEND_SNAPSHOT:
/* Task 3.5: snapshot transfer — stub */
/* Task 3.5: snapshot transfer.
* Creates a checkpoint in the delaymgr thread (not here — vtask
* must not block), then sends the snapshot in 64KB chunks. */
INFO("HA repl: standby[%d] lsn=%" PRIu64
" < oldest_wal_lsn=%" PRIu64 " → snapshot (stub)",
" < oldest_wal_lsn=%" PRIu64 " → requesting snapshot transfer",
peer_idx, standby_lsn, oldest_wal_lsn);
if (c && c->persist.snap_path[0]) {
extern int ha_send_snapshot_to_standby(endpoint_t *, const char *,
uint64_t, uint64_t);
ha_send_snapshot_to_standby(ep, c->persist.snap_path,
c->persist.committed_lsn,
/*total_size placeholder*/ 131072);
}
break;
case HA_REPL_STREAM_WAL: