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

@ -30,6 +30,7 @@ const char* argp_program_bug_address = BUG_EMAIL;
#define OPT_VCPUS 259
#define OPT_CERTDIR 260
#define OPT_SYNC_TIMEOUT 261
#define OPT_WAL_SYNC 262
struct arguments {
char* myname;
@ -42,6 +43,7 @@ struct arguments {
int vcpus;
char* certdir;
uint32_t sync_timeout_ms;
uint32_t wal_sync_ms;
};
static struct argp_option options[] = {
@ -62,6 +64,8 @@ static struct argp_option options[] = {
"Directory containing xce.crt and xce.key (default: <workdir>/certs)" },
{ "sync-timeout-ms", OPT_SYNC_TIMEOUT, "MS", 0,
"Synchronous majority-replication commit barrier timeout in ms (0 = default)" },
{ "wal-sync-ms", OPT_WAL_SYNC, "MS", 0,
"WAL flush (fsync) cadence in ms (0 = default)" },
{ 0 }
};
@ -111,6 +115,13 @@ static error_t parse_opt(int key, char* arg, struct argp_state* state)
arguments->sync_timeout_ms = (uint32_t)v;
break;
}
case OPT_WAL_SYNC: {
int v = atoi(arg);
if (v < 0)
argp_error(state, "--wal-sync-ms must be >= 0 (got: %s)", arg);
arguments->wal_sync_ms = (uint32_t)v;
break;
}
default:
return ARGP_ERR_UNKNOWN;
}
@ -163,6 +174,7 @@ int main(int argc, char* argv[])
arguments.conf_stale_timeout = 86400;
arguments.vcpus = 0; /* 0 = not set; use cluster config default */
arguments.sync_timeout_ms = 0; /* 0 = not set; use persist config default */
arguments.wal_sync_ms = 0; /* 0 = not set; use persist config default */
argp_parse(&argp, argc, argv, 0, 0, &arguments);
@ -212,6 +224,7 @@ int main(int argc, char* argv[])
myconf.conf_stale_timeout = (time_t)arguments.conf_stale_timeout;
myconf.vcpus = arguments.vcpus;
myconf.sync_timeout_ms = arguments.sync_timeout_ms;
myconf.wal_sync_ms = arguments.wal_sync_ms;
memset(&myconf.peers_cfg, 0, sizeof(myconf.peers_cfg));
if (arguments.peers_str) {