forked from lei.chen/myxce
feat: implement persist_checkpoint with WAL marker, snapshot, trim, rotation (P0-3)
- persist_write_checkpoint_marker(): writes WAL_CHECKPOINT header entry
with CRC, increments current_lsn; never updates last_replicated_crc
(checkpoint markers are local-only, never replicated)
- write_snapshot(): atomic tmp→rename write of P0 sentinel snapshot
("XCESNAP\0" + checkpoint_lsn); full Cap'n Proto body in Task 11
- trim_wal_segments(): removes seg-*.wal files whose start LSN is
strictly less than checkpoint_lsn
- rotate_snapshots(): collects .capnp files, sorts by name (LSN order),
deletes oldest beyond snap_keep_n
- persist_checkpoint(): EBUSY guard via atomic_exchange, sequences
marker→lsn record→snapshot→trim→rotate, clears flag on exit
- 5 TDD tests in test_persist_checkpoint.c covering: snapshot file
creation, checkpoint_lsn advance, WAL lsn advance, EBUSY guard,
and rotation keeping at most snap_keep_n files
- All 18 controller unit tests pass (0 failures)
This commit is contained in:
parent
813a5a3359
commit
e76f76a88a
4 changed files with 391 additions and 6 deletions
|
|
@ -8,6 +8,7 @@
|
|||
extern void test_persist_types(void);
|
||||
extern void test_persist_wal(void);
|
||||
extern void test_persist_schema(void);
|
||||
extern void test_persist_checkpoint(void);
|
||||
|
||||
void setUp(void) { return; }
|
||||
|
||||
|
|
@ -85,6 +86,7 @@ int main(int argc, char* argv[])
|
|||
TEST(test_persist_types);
|
||||
TEST(test_persist_wal);
|
||||
TEST(test_persist_schema);
|
||||
TEST(test_persist_checkpoint);
|
||||
|
||||
return UNITY_END();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue