feat(ha-term-safety): route AppendEntries intake through library + leaderCommit wire (task 3.2)

This commit is contained in:
Rongsong Shen 2026-06-22 08:42:35 +00:00
parent 6a519a928b
commit 754e586f8f
10 changed files with 508 additions and 168 deletions

View file

@ -379,11 +379,13 @@ int repl_send_append_entries(replicator_t *r, int peer_idx,
memset(&entry, 0, sizeof(entry));
entry.prev_log_index = prev_log_index;
entry.prev_log_term = prev_log_term;
/* NOTE: leader_commit is accepted as a parameter (and captured by the test
* seam) but is NOT yet wire-encoded — WalCatchupEntry has no leaderCommit
* field. Adding that capnp field and the standby-side intake of leader_commit
* is deferred to task 3.2; no standby acts on it until then.
* A heartbeat is marked by n_entries==0 (zero entries; lsn left 0). */
/* ha-term-safety task 3.2: leader_commit is now wire-encoded on the
* top-level container (WalCatchupEntry.leaderCommit @7) so the standby intake
* passes it into raft_on_append_entries_request. entry is entries[0] — the
* AppendEntries metadata holder; the encoder reads the prev tuple +
* leader_commit from it for both the heartbeat (n_entries==0) and the
* single-entry (n_entries==1) AE. A heartbeat carries zero entries. */
entry.leader_commit = leader_commit;
if (n_entries == 1) {
entry.lsn = entry_lsn;
entry.entry_type = entry_type;