Expand description
Per-actor admission control for the HTTP server (MR-686 §VII.A).
The HTTP server’s previous global RwLock<Omnigraph> serialized every
mutating request across all actors. PR 2 removes that lock — engine
APIs are now &self, so concurrent calls from different actors can
run against Arc<Omnigraph> simultaneously. Without admission
control, one heavy actor can exhaust shared capacity (Lance I/O
threads, manifest churn, network) and starve other actors.
This module provides:
-
Per-actor in-flight count cap: each actor has a
tokio::sync::SemaphorewithOMNIGRAPH_PER_ACTOR_INFLIGHT_MAXpermits (default 16).try_acquire_owned()returnsErrwhen exhausted; the server maps this to HTTP 429. -
Per-actor in-flight byte budget: each actor accumulates an
AtomicU64byte estimate.fetch_add(est_bytes)then a check againstbyte_capis race-free via decrement-on-rejection. The server maps an over-budget result to HTTP 429 as well.
Counts are governed by the semaphore (race-free try_acquire_owned()
enforces the cap atomically); bytes use fetch_add + decrement-on-
rejection. Both checks are atomic compare-and-act, never
load-then-act — the test
actor_admission_race_does_not_exceed_cap pins this contract by
spawning 32 concurrent try_admit calls against a cap of 16 and
asserting exactly 16 succeed.
Acquisition order against the engine’s per-(table, branch) write
queue: admission FIRST (the HTTP handler reserves capacity before
calling into the engine), engine queue SECOND (acquired inside
MutationStaging::commit_all). This composes cleanly because
admission is a single per-actor count + budget check, never
cross-actor; nothing the engine does can change a peer actor’s
admission state.
Structs§
- Admission
Guard - Drop-on-completion guard for an admitted request. Dropping releases
the in-flight count permit (via
Dropon the underlying semaphore permit) and decrements the actor’s byte counter. - Workload
Controller - Server-side per-actor admission controller. Constructed once at
server startup and shared via
Arc<WorkloadController>onAppState.
Enums§
- Reject
Reason - Why a
try_admitcall returnedErr. The server maps each variant to a specific HTTP response code; seeWorkloadControllerdocs.
Constants§
- DEFAULT_
PER_ ACTOR_ BYTES_ MAX - Default per-actor in-flight byte budget (4 GiB). Override via
OMNIGRAPH_PER_ACTOR_BYTES_MAX. - DEFAULT_
PER_ ACTOR_ INFLIGHT_ MAX - Default per-actor in-flight count cap. Override via
OMNIGRAPH_PER_ACTOR_INFLIGHT_MAX.