feat(raft-drive-async): SlowLane bounded executor for long blocking I/O (task 1.2)
Dedicated-pthread pool isolated from the vtask pool; non-blocking slowlane_submit (0 enqueued / -EEXIST deduped / -EAGAIN cap-full-deferred), admission cap on running tasks, per-key in-flight dedup, run-exactly-once, drain+join fini. Wired into controller lifecycle (dormant; consumers land in 2.x/3.x). 7 unit tests, mutation-verified cap+dedup; full suite 194/0 green, 15x ASAN.
This commit is contained in:
parent
729055a37f
commit
5650acd375
8 changed files with 710 additions and 1 deletions
|
|
@ -1367,6 +1367,25 @@ int cluster_init_phase2(cluster_t* c)
|
|||
}
|
||||
}
|
||||
|
||||
/* raft-drive-async task 1.2: bring up the SlowLane executor — the dedicated
|
||||
* bounded-thread offload lane for long blocking I/O (snapshot transfer,
|
||||
* config-push, peer reconnect) that must never run on the iomgr/delaymgr
|
||||
* drive threads. Dormant infra here: no production caller until the
|
||||
* reconnect (2.x) / snapshot/config-push (3.x) offloads land. Sized from
|
||||
* the DEFAULT_SLOWLANE_* constants (task 1.1, config.h). Guard c->slowlane
|
||||
* so the legacy two-phase path (phase2 can run twice) inits exactly once. */
|
||||
if (c->slowlane.workers == NULL) {
|
||||
rc = slowlane_init(&c->slowlane, DEFAULT_SLOWLANE_WORKERS,
|
||||
DEFAULT_SLOWLANE_MAX_INFLIGHT);
|
||||
if (rc != 0) {
|
||||
ERROR("slowlane_init failed: %d (workers=%d, max_inflight=%d)",
|
||||
rc, DEFAULT_SLOWLANE_WORKERS, DEFAULT_SLOWLANE_MAX_INFLIGHT);
|
||||
return rc;
|
||||
}
|
||||
INFO("drive-async: slowlane up (workers=%d, max_inflight=%d)",
|
||||
DEFAULT_SLOWLANE_WORKERS, DEFAULT_SLOWLANE_MAX_INFLIGHT);
|
||||
}
|
||||
|
||||
/* Role set by ha_elect_evaluate_and_signal() inside cluster_run() */
|
||||
if (ha_is_primary(&c->ha))
|
||||
ha_promote_to_primary(c);
|
||||
|
|
@ -1743,6 +1762,12 @@ void cluster_fini(cluster_t* c)
|
|||
/* Stop HA watchdog thread before tearing down other subsystems — P1-5 */
|
||||
ha_fini(&c->ha);
|
||||
|
||||
/* raft-drive-async task 1.2: drain + join the SlowLane after the drive
|
||||
* threads have stopped submitting (ha_fini above) and before persist/iomgr
|
||||
* teardown, since lane tasks (snapshot/reconnect, once wired) touch those.
|
||||
* No-op if phase2 never ran (workers==NULL guard inside slowlane_fini). */
|
||||
slowlane_fini(&c->slowlane);
|
||||
|
||||
/* Stop persistence before tearing down the rest */
|
||||
persist_stop(&c->persist);
|
||||
persist_fini(&c->persist);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue