forked from lei.chen/myxce
feat(ha-term-safety): on_get_entry_term + on_truncate_from callback bodies (task 2.2)
on_get_entry_term → persist_entry_term (recorded term, 0=absent, legacy-0→1; caveat documented per 1.3 review). on_truncate_from → persist_truncate_wal_above(p, index-1) (delete LSN>=index), returns rc for library/leader retry; non-promotable fence intact; replaces the committed-boundary heuristic on the library-driven path. New truncate_term_index_locked keeps the in-memory per-LSN term index consistent on both truncate paths (under lock, cutoff-aligned) → no stale-term read after truncation. 3 tests, reviewer APPROVED, per-group 0 failures.
This commit is contained in:
parent
8f3d3ce8f4
commit
ed2443533f
5 changed files with 210 additions and 5 deletions
|
|
@ -771,6 +771,24 @@ int handle_request_vote(ha_state_t *ha,
|
|||
*/
|
||||
int ha_cb_persist_entry_for_test(ha_state_t *ha, uint64_t index, uint64_t term,
|
||||
const void *entry, size_t len);
|
||||
|
||||
/*
|
||||
* ha_cb_get_entry_term_for_test (ha-term-safety task 2.2): invoke the WIRED
|
||||
* on_get_entry_term callback directly so a unit test exercises the real
|
||||
* entry-term accessor (persist_entry_term at the given 1-based index == LSN).
|
||||
* Returns the recorded term (legacy-0 mapped to WAL_LEGACY_TERM), or 0 when the
|
||||
* LSN is absent. TEST-ONLY.
|
||||
*/
|
||||
uint64_t ha_cb_get_entry_term_for_test(ha_state_t *ha, uint64_t index);
|
||||
|
||||
/*
|
||||
* ha_cb_truncate_from_for_test (ha-term-safety task 2.2): invoke the WIRED
|
||||
* on_truncate_from callback directly so a unit test exercises the real conflict
|
||||
* truncation (delete local entries at LSN >= index). Returns the truncate rc
|
||||
* (0 on success; non-zero propagates so the library/leader retries while the
|
||||
* member stays non-promotable). TEST-ONLY.
|
||||
*/
|
||||
int ha_cb_truncate_from_for_test(ha_state_t *ha, uint64_t index);
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue