forked from lei.chen/myxce
feat(raft-drive-async): LivenessAdmission pool reservation + commit fold (tasks 1.6/1.7)
vtaskmgr gains vtask_class_t (LIVENESS/LIVE_BLOCK/REQ_BLOCK) + a pool-level blocking reservation: REQ_BLOCK fast-rejects -XCE_ERR_NOT_READY past n_vcpus-R; LIVENESS never gated (deadlock-freedom). commit_submit folds its inflight_waits onto the pool via commit_set_pool; production wired in cluster.c phase2 (vtaskmgr_set_liveness_reserved(R) + commit_set_pool). Lock order p->lock->ce->lock->blk_lock. Dormant until 3.1. Commit suites 38/30/22/38 green; lib 282/0, controller 196/0, ASAN clean. Phase 1 done.
This commit is contained in:
parent
0781c6c027
commit
a36234a103
12 changed files with 721 additions and 22 deletions
|
|
@ -12,8 +12,13 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#include "persist.h" /* persist_t (owns committed_lsn atomic + replicator_t registry) */
|
||||
#include "vtaskmgr.h" /* vtaskmgr_t — LivenessAdmission blocking-admission seam */
|
||||
|
||||
/* Headroom kept free of blocking commit waits; cap = max(1, n_vcpus - reserved) */
|
||||
/* Headroom kept free of blocking commit waits; cap = max(1, n_vcpus - reserved).
|
||||
* Used ONLY by the local (no-pool) admission fallback. When a vtaskmgr pool is
|
||||
* wired (commit_set_pool, raft-drive-async task 1.6), the pool owns the single
|
||||
* reservation (cap = max(1, n_vcpus - VTASK_LIVENESS_RESERVED)) and this
|
||||
* constant is not consulted. */
|
||||
#define COMMIT_WAIT_RESERVED 2
|
||||
|
||||
typedef enum { COMMIT_MODE_WAIT, COMMIT_MODE_RETAIN } commit_mode_t;
|
||||
|
|
@ -29,7 +34,13 @@ typedef struct commit_engine {
|
|||
persist_t* p; /* back-reference: committed_lsn store + repl registry */
|
||||
int n_peers;
|
||||
int n_vcpus;
|
||||
int inflight_waits; /* <= max(1, n_vcpus - COMMIT_WAIT_RESERVED) */
|
||||
/* raft-drive-async task 1.6: when non-NULL, commit-wait admission is folded
|
||||
* onto the vtaskmgr pool's single LivenessAdmission reservation (the pool
|
||||
* owns the cap). When NULL (commit-only unit fixtures), the legacy local
|
||||
* cap max(1, n_vcpus - COMMIT_WAIT_RESERVED) is used. inflight_waits is
|
||||
* maintained in BOTH modes as the observable in-flight commit-wait count. */
|
||||
vtaskmgr_t* pool;
|
||||
int inflight_waits; /* in-flight blocking commit waits */
|
||||
uint64_t writable_lsn; /* own-term gate; 0 = no gate */
|
||||
/* ha-term-safety commit-ceiling-optA: the raft library's commit_index,
|
||||
* recorded for OBSERVABILITY / TRACE / conformance-oracle ONLY. It does NOT
|
||||
|
|
@ -48,6 +59,14 @@ typedef struct commit_engine {
|
|||
int commit_engine_init(commit_engine_t* ce, persist_t* p, int n_peers, int n_vcpus);
|
||||
void commit_engine_fini(commit_engine_t* ce);
|
||||
|
||||
/* raft-drive-async task 1.6: fold commit-wait admission onto the vtaskmgr
|
||||
* pool's single LivenessAdmission reservation. After this, commit_submit(WAIT)
|
||||
* acquires a pool blocking-admission slot (cap = n_vcpus - VTASK_LIVENESS_RESERVED)
|
||||
* instead of using the local COMMIT_WAIT_RESERVED cap. pool == NULL restores
|
||||
* the local fallback. Call once at wiring time (cluster_init_phase2), after the
|
||||
* pool's liveness reservation is set. */
|
||||
void commit_set_pool(commit_engine_t* ce, vtaskmgr_t* pool);
|
||||
|
||||
/* Register entry at append time. RETAIN returns 0 immediately.
|
||||
* WAIT blocks up to timeout_ms: 0 = committed; -ETIMEDOUT = not committed
|
||||
* (entry remains in log; outcome resolves per umbrella 2.5); -XCE_ERR_NOT_READY =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue