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
|
|
@ -38,7 +38,7 @@
|
|||
- _Requirements: 1.1, 1.2, 1.3, 1.4_
|
||||
- _Depends: 1.3_
|
||||
|
||||
- [ ] 2.2 Implement `on_get_entry_term` and `on_truncate_from`
|
||||
- [x] 2.2 Implement `on_get_entry_term` and `on_truncate_from`
|
||||
- `on_get_entry_term` answers from the recovered/live per-LSN term index (legacy-0 rule from 1.3); `on_truncate_from` deletes entries at index..end via the existing LSN truncate, replacing the committed-boundary heuristic
|
||||
- Observable completion: the library reads back a stamped entry term via the callback; a truncate-from call removes the local suffix at and above the index and leaves the prefix intact
|
||||
- _Requirements: 1.5, 1.8, 3.1, 3.2_
|
||||
|
|
@ -153,3 +153,5 @@
|
|||
- **DEFERRED to task 3.1 (review):** primary path uses persist_wal_async's `current_lsn`, NOT the library `index` — holds only while `s->log_len` and `p->current_lsn` stay co-tracked. Task 3.1 MUST retire/disable the hand-rolled primary append so no WAL append bypasses raft_log_append, else current_lsn diverges from s->log_len. Also: persist_set_term + write are two lock regions (safe today, no concurrent appender) — 3.1 should re-verify when real concurrent appends exist.
|
||||
- **DEFERRED to task 3.2 (review):** a heartbeat / 0-entry AppendEntries must NOT call on_persist_entry (entry==NULL,len==0 currently falls through to WAL_NOOP) — verify the library only calls on_persist_entry when there is an entry.
|
||||
- **3.1/3.2 producer format:** must pack `raft_entry_blob_t {type,payload_len}+payload` to match the on_persist_entry unpack (single shared def in wal_types.h).
|
||||
|
||||
- **2.2 done.** on_get_entry_term → persist_entry_term (legacy-0 caveat documented per 1.3 review); on_truncate_from → persist_truncate_wal_above(p,index-1) (delete LSN>=index), returns rc, non-promotable fence preserved. NEW `truncate_term_index_locked` (persist.c) shrinks the in-memory term index on BOTH truncate return paths (under p->lock, cutoff-aligned) so on_get_entry_term returns 0 for truncated LSNs — no stale-term hazard. 3 tests. Reviewer APPROVED.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue