feat(ha-term-safety): drive raft_log_append on primary append path (task 3.1)
This commit is contained in:
parent
3dd8493fff
commit
6a519a928b
5 changed files with 299 additions and 11 deletions
|
|
@ -2032,7 +2032,19 @@ int persist_wal_sync_append(persist_t* p, uint32_t type,
|
|||
const void* payload, uint32_t len,
|
||||
int* sync_rc_out)
|
||||
{
|
||||
int rc = persist_wal_async(p, type, payload, len);
|
||||
/* ha-term-safety task 3.1: the primary's WAL_JOB_SUBMIT append is routed
|
||||
* through the raft library (ha_primary_log_append → raft_log_append) so the
|
||||
* library stamps the term + assigns the LSN (firing on_persist_entry → the
|
||||
* WAL write), keeping p->current_lsn co-tracked with s->log_len; the existing
|
||||
* majority-commit barrier below (repl_wait_majority_ack) is UNCHANGED and runs
|
||||
* after the append. Non-raft road / engine-less tests (library not LEADER)
|
||||
* fall back inside ha_primary_log_append to persist_wal_async. Standalone
|
||||
* persist (p->cluster == NULL, lib-level tests) keeps the direct append. */
|
||||
int rc;
|
||||
if (p->cluster != NULL)
|
||||
rc = ha_primary_log_append(p->cluster, type, payload, len, NULL);
|
||||
else
|
||||
rc = persist_wal_async(p, type, payload, len);
|
||||
if (rc != 0) {
|
||||
if (sync_rc_out)
|
||||
*sync_rc_out = rc;
|
||||
|
|
@ -2305,7 +2317,19 @@ static int wal_hook_append_classified(persist_t* p, uint32_t wal_type,
|
|||
uint64_t appended_lsn;
|
||||
int rc;
|
||||
|
||||
rc = persist_wal_async(p, wal_type, payload, len);
|
||||
/* ha-term-safety task 3.1: route the primary's local append through the raft
|
||||
* library (ha_primary_log_append → raft_log_append) so the LIBRARY stamps the
|
||||
* live election term and assigns the LSN (firing on_persist_entry → the WAL
|
||||
* write), keeping p->current_lsn co-tracked with s->log_len. The library is
|
||||
* the SINGLE primary append entry — no append bypasses it on the raft road.
|
||||
* On the non-raft road (library not LEADER) ha_primary_log_append falls back
|
||||
* to persist_wal_async, so engine-less / init-time contexts are unchanged.
|
||||
* When p->cluster is NULL (persist used standalone in lib tests) keep the
|
||||
* direct append (no cluster → no raft state to drive). */
|
||||
if (p->cluster != NULL)
|
||||
rc = ha_primary_log_append(p->cluster, wal_type, payload, len, NULL);
|
||||
else
|
||||
rc = persist_wal_async(p, wal_type, payload, len);
|
||||
if (rc != 0 || mode != WAL_MODE_RETAIN)
|
||||
return rc;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue