feat: persist.c WAL writer with chained CRC32 and dedicated fsync pthread (P0-1)

- Expose persist_t struct concretely in persist.h (opaque pattern deferred)
- persist_set_workdir() derives wal/snap paths from workdir+name
- persist_init() creates WAL/snap directories, rejects NFS mounts
- persist_wal_async() writes WAL entries with chained CRC32 via zlib
- Dedicated fsync pthread fires every wal_sync_ms milliseconds
- persist_flush() forces fdatasync for tests and clean shutdown
- WAL_CHECKPOINT type rejected with -EINVAL (never written via async path)
- Stubs: persist_recover, persist_wal_sync_append, persist_checkpoint
- Add fsync_thread_running flag to guard persist_stop when thread not started
- Add zlib_dep to controller and unit test meson targets
- 3 new TDD tests: init_creates_directories, wal_async_writes_entry,
  checkpoint_type_rejected — all GREEN
This commit is contained in:
Rongsong Shen 2026-05-07 10:00:10 +00:00
parent d66a8a98b6
commit b0a5fbb4e9
5 changed files with 502 additions and 2 deletions

View file

@ -6,6 +6,7 @@
#include <unity/unity.h>
extern void test_persist_types(void);
extern void test_persist_wal(void);
void setUp(void) { return; }
@ -81,6 +82,7 @@ int main(int argc, char* argv[])
UNITY_BEGIN();
TEST(test_persist_types);
TEST(test_persist_wal);
return UNITY_END();
}