fix(ha-repl-hardening): wire snapshot production path (task 3.5b)
- SEND_SNAPSHOT uses checkpoint_lsn (not committed_lsn) for file lookup - ha_send_snapshot_to_standby stats file for actual total_size - ha_compute_oldest_wal_lsn scans WAL dir for min segment LSN - Removed hardcoded 131072 and oldest_wal_lsn=0 placeholders
This commit is contained in:
parent
834ab4d5e7
commit
318098c727
5 changed files with 43 additions and 18 deletions
|
|
@ -1075,18 +1075,14 @@ int ha_dispatch_repl_action_for_standby(ha_state_t *ha,
|
|||
break;
|
||||
|
||||
case HA_REPL_SEND_SNAPSHOT:
|
||||
/* 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 " → 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);
|
||||
uint64_t);
|
||||
ha_send_snapshot_to_standby(ep, c->persist.snap_path,
|
||||
c->persist.committed_lsn,
|
||||
/*total_size placeholder*/ 131072);
|
||||
c->persist.checkpoint_lsn);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -2249,12 +2245,15 @@ static int repl_ack_decode_and_dispatch(endpoint_t *ep, vote_ep_ctx_t *vctx)
|
|||
sr.config_tag, sr.applied_lsn,
|
||||
committed_tag, committed_lsn);
|
||||
|
||||
/* Task 3.3: run the unified decision loop for this standby.
|
||||
* oldest_wal_lsn=0 until snapshot transfer is wired (Task 3.5). */
|
||||
/* Derive oldest_wal_lsn from the WAL directory.
|
||||
* The oldest retained segment's start LSN is the boundary —
|
||||
* standbys below it need a snapshot (Task 3.5b). */
|
||||
uint64_t oldest_wal_lsn = 0;
|
||||
#ifndef XCE_TESTING
|
||||
if (c)
|
||||
oldest_wal_lsn = 0; /* Task 3.5: wire persist->oldest_wal_lsn */
|
||||
if (c && c->persist.wal_path[0]) {
|
||||
extern uint64_t ha_compute_oldest_wal_lsn(const char *wal_path);
|
||||
oldest_wal_lsn = ha_compute_oldest_wal_lsn(c->persist.wal_path);
|
||||
}
|
||||
#endif
|
||||
ha_dispatch_repl_action_for_standby(ha, c, ep, peer_idx,
|
||||
committed_tag, committed_lsn,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue