forked from lei.chen/myxce
feat(raft-drive-async): add drive-async config constants + liveness-reservation helper (task 1.1)
drive_async_liveness_reserved = max(1, min(n_peers-1, n_vcpus-1)) — single source of truth for VTASK_LIVENESS_RESERVED (deadlock-freedom floor applied last). New DEFAULT_CONNECT_TIMEOUT_MS / DEFAULT_SLOWLANE_* constants. Resolved reservation logged at init; under-provisioned (n_vcpus<n_peers) clamp WARNs loudly, never self-terminates. 8 unit cases, mutation-verified.
This commit is contained in:
parent
295769d8ae
commit
729055a37f
8 changed files with 329 additions and 0 deletions
|
|
@ -580,6 +580,24 @@ uint64_t ha_promotion_truncate_floor(uint64_t safe_lsn, uint64_t durable_tip)
|
|||
return safe_lsn > durable_tip ? safe_lsn : durable_tip;
|
||||
}
|
||||
|
||||
/* ── raft-drive-async task 1.1: peer-scaled liveness reservation ─────────────
|
||||
*
|
||||
* Pure: reserved = max(1, min(n_peers - 1, n_vcpus - 1)). The floor of 1 is
|
||||
* applied LAST so deadlock-freedom (>=1 guaranteed-free liveness worker) holds
|
||||
* even when the n_vcpus ceiling would otherwise drive the value to 0 (e.g.
|
||||
* n_vcpus == 1). See ha.h for the full rationale; the caller WARNs on the
|
||||
* under-provisioned (n_vcpus < n_peers) clamp — this helper never logs. */
|
||||
int drive_async_liveness_reserved(int n_peers, int n_vcpus)
|
||||
{
|
||||
int desired = n_peers - 1; /* worst-case concurrent liveness work */
|
||||
int ceiling = n_vcpus - 1; /* keep >=1 commit (REQ_BLOCK) slot */
|
||||
|
||||
int reserved = desired < ceiling ? desired : ceiling; /* min(desired, ceiling) */
|
||||
if (reserved < 1) /* floor applied LAST — always wins */
|
||||
reserved = 1;
|
||||
return reserved;
|
||||
}
|
||||
|
||||
/* ── ha-commit-durability task 4.3: pre-promotion eligibility gate ───────────
|
||||
*
|
||||
* ha_promotion_gate_decision: pure decision (Req 2.2, 2.5, 2.6). Build the Boot
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue