feat(ha-config-bootstrap): implement persist_truncate_wal_above and committed_lsn (task 7.5)

This commit is contained in:
Rongsong Shen 2026-05-28 14:13:29 +00:00
parent e7da075315
commit 85c8565957
3 changed files with 151 additions and 1 deletions

View file

@ -68,6 +68,7 @@ struct persist_s {
uint64_t term;
uint32_t seg_offset;
uint64_t checkpoint_lsn;
_Atomic uint64_t committed_lsn; /* highest LSN known committed; invariant: <= current_lsn - 1 */
uint64_t total_wal_bytes;
char seg_path[4096];
@ -121,6 +122,10 @@ int persist_flush(persist_t* p);
/* Checkpoint */
int persist_checkpoint(persist_t* p);
/* WAL truncation — remove all entries with LSN > cutoff_lsn.
* Idempotent; returns 0 on success, negative errno on I/O error. */
int persist_truncate_wal_above(persist_t* p, uint64_t cutoff_lsn);
/* Logging helper — never logs payload content (security invariant) */
void persist_log_entry_metadata(const wal_entry_hdr_t* hdr);