feat(ha-commit-durability): add --wal-sync-ms flush-cadence override (task 1.1)

This commit is contained in:
Rongsong Shen 2026-06-18 04:46:01 +00:00
parent 80bb1d766e
commit 1ca2d640cb
7 changed files with 206 additions and 0 deletions

View file

@ -36,6 +36,7 @@ typedef struct {
int conf_stale; /* 1 when saved config older than conf_stale_timeout */
int vcpus; /* Req 4.3: --vcpus CLI value; 0 = use config default */
uint32_t sync_timeout_ms; /* --sync-timeout-ms; 0 = use persist default */
uint32_t wal_sync_ms; /* --wal-sync-ms; 0 = use persist default */
} myconf_t;
extern cluster_config_t* get_default_conf(void*);

View file

@ -42,6 +42,24 @@ static inline persist_config_t persist_config_defaults(void)
return c;
}
/*
* persist_config_set_wal_sync_ms — apply the --wal-sync-ms flush-cadence
* override (ha-commit-durability Req 3.1).
*
* Single override point shared by both persist_config_defaults() callers
* (cluster.c phase2 and myapp.c step 6), mirroring the --sync-timeout-ms
* convention: override_ms == 0 means "flag not passed" and leaves the
* default flush cadence untouched (Req 3.3 — the seam changes timing
* controllability only, not the durability contract). A positive value
* sets the cadence to exactly that, applied before persistence starts.
*/
static inline void persist_config_set_wal_sync_ms(persist_config_t *c,
uint32_t override_ms)
{
if (override_ms > 0)
c->wal_sync_ms = override_ms;
}
/* ============================================================
* Key→index mapping for checkpoint serialization (Part 3.8)
* ============================================================ */