Plan: Audit Batched Claims — One Commit per Batch for the Audit Subscriber (#2765)
- Status
- Context
- Design
- D1. The opt-in API (craig-mq)
- D2. The round (session side, new
crates/craig-mq/src/subscriber_batch.rs) - D3. Lock-hold budget and admission
- D4. One envelope inside the batch, and the commit phase
- D5. Deferred claims
- D6. Commit, settlement and arbitration
- D7. Failure semantics
- D8. Per-envelope times and the detection guarantee
- D9. Observability and the transaction-count oracle
- D10. Pool and deployment
- Scope
- U1 —
docs(adr): amend ADR-062 for an opted-in batched inbox(weight 2, P2-medium,docs/abc-u1-adr-062-batch-amendment, after plan approval) - U2 —
feat(mq): run a batch of inbox attempts in one transaction(weight 8, P2-medium,feat/abc-u2-inbox-batch, after U1, #2770) - U3 —
feat(mq): opt a subscription into batched inbox claims(weight 5, P2-medium,feat/abc-u3-batched-subscription, after U2) - U4 —
fix(security): batch the audit subscriber’s inbox claims so one commit carries many envelopes(#2765; weight 5, P2-medium,fix/abc-u4-audit-batch, after U3)
- U1 —
- Out of scope
- Risks
- Review log
Status
Done (2026-11-12) — all four units merged; the audit subscriber batches at 16 by default after the 2026-11-12 re-measurement (#2765).
Context
-
The cap. craig-security’s audit subscriber binds
#: every fleet event passes one serial consumer running one transaction and oneCOMMITper envelope (inbox.rshandle_idempotently,subscriber.rsrun_sessionin craig-mq), so commit latency bounds its throughput. The sink once fell 67 s behind (#2699);cargo xtask diag inbox-latencyran 1289 envelopes/s at baseline and 8–60/s once WAL load stretched commit p50 to 88 ms. That is susceptibility, not the incident’s cause (#2699 keeps it). Batching amortizes the commit; U4 measures the gain through the real subscriber, and the measurement decides the default. -
What it re-decides. ADR-062’s "one transaction per attempt", for an opted-in subscriber (U1, before U2; #2765 AC1); other
subscribe_idempotentconsumers keep their behaviour and SQL. Binding input: #2765’s constraints and criteria, with one amendment (D6: a failed batch is arbitrated locally, not requeued); itscreated_atisaudit_log.timestamp. Prerequisite #2770 gives the single path theresyncD4 reuses. On approval U1–U3 become child issues of a new epic (Plan::AUDIT-BATCHED-CLAIMS) holding #2765 as U4.
Design
D1. The opt-in API (craig-mq)
-
crates/craig-mq/src/inbox_batch.rs(new, re-exported at the crate root):-
BatchPolicy::new(max_envelopes: u16) → Result<BatchPolicy, BatchPolicyError>(thiserror) refuses 0 and anything abovePREFETCH(16,subscriber.rs:56, raised topub(crate)). -
BatchInbox<'a, E> { pool, publisher, policy, is_statement_timeout: fn(&E) → bool }. The classifier recognises the batch’s 2 s cap in a handler error (Ecarries no SQLSTATE); craig-security’s downcastsanyhow::Errortosqlx::Errorand tests57014. -
pub async fn handle_batch(inbox: &BatchInbox<'_, E>, consumer_queue, envelopes: Vec<EventEnvelope>, handler: H) → BatchReport<E>: oneBatchVerdictper input, in input order:Committed(Committed<E>),Deferred(DeferReason),CarriedorArbitrate(the batch failed, D6).finish_committed(inbox, consumer_queue, Committed<E>) → Result<(), InboxError<E>>runs one delivery’s post-commit work and returns whathandle_idempotentlywould have, so it settles exactly as today. A counted failure carries the textinvoke_handlerrendered before the commit.
-
-
Subscriber::subscribe_idempotent_batched(&self, inbox: BatchInbox<'_, E>, queue_name, routing_keys, shutdown, heartbeat, handler); handler bound, queue declaration and settle label assubscribe_idempotent’s. The doc states the handler obligations: `now()is the batch’s start, so per-event times useclock_timestamp()(D8); a handler sets noSET LOCAL(it would persist into later envelopes) and takes no savepoint (D3’s subtransaction cap).
D2. The round (session side, new crates/craig-mq/src/subscriber_batch.rs)
run_batch_session replaces run_session for a batched subscription, in a supervise_batched loop mirroring
supervise_regular; the session helpers it shares (next_delivery, the settle helpers, run_contained_handler,
SessionEnd, ReceiveClock) become pub(crate). One round:
-
Collect: wait with
next_deliveryunless carried deliveries are held, then take those, the one waited for and the buffered ones (consumer.next().now_or_never()), up to K; undecodable bodies and consumer errors as today. -
Partition: a
redelivereddelivery goes solo, never into a batch; the rest are candidates in arrival order. -
Batch: the candidates run through
handle_batchin onecontainboundary (#1203) ending at the confirmed commit. -
Settle: ack every committed delivery that needs no post-commit work (
multiple: false) and beat; then, in arrival order, each one that does:finish_committedinside its owncontain, settle as today, beat. -
Arbitrate: when the batch failed, its admitted and deferred deliveries join the solo list, still unacked.
-
Solo: the solo list (redelivered, deferred, arbitrated) runs through
run_contained_handleroverhandle_idempotently, beating after each and checking shutdown between; carried deliveries lead the next round.
D3. Lock-hold budget and admission
A batch holds every claimed row’s lock until its COMMIT, so the batch must fit ADR-062’s bound (adr-062:81-84): a
duplicate waits under the 30 s default statement_timeout (craig-db statement_timeout_ms). The constants live in
inbox_batch.rs; compile-time asserts pin the reserve’s sum, a positive cutoff and BATCH_HOLD_BUDGET < 30 s.
| Constant | Value | Bounds |
|---|---|---|
|
50 ms |
|
|
1 s |
each claim-phase statement (the |
|
2 s |
each restamp-, handler- and completion-phase statement |
|
5 s |
one handler future (expiry defers the envelope uncounted, D4) |
|
15 s |
worst path 13 s: claim 1 s + |
|
1 s |
the commit phase’s |
|
1 s |
each statement’s client-side timeout is its server timeout plus this; expiry aborts the batch |
|
21 s |
first claim statement to the end of `COMMIT’s interruptible work |
|
5 s |
|
Admission is a pure fn admit(hold: Duration, admitted: usize, policy: BatchPolicy) → Admission, called before each
claim: it flushes with Count once K are admitted, with Budget when hold > ADMIT_CUTOFF, and otherwise admits;
hold runs on tokio’s clock from the first claim statement, so the first envelope is always admitted. Running out of
candidates is Drained; a flushed remainder is Carried.
The bound is conditional. Every interruptible wait is bounded (server and client timeouts per statement, the
handler deadline, resync): an envelope admitted at hold ≤ 5 s ends its worst path by 18 s, the commit phase’s
interruptible work by 19 s. The WAL flush inside COMMIT (a critical section) and a transport stall the server has
not noticed are not interruptible; the single path shares both, so ADR-062’s 21 s is equally conditional (U1 says
so). Beyond the bound a duplicate’s claim fails at its 30 s timeout, uncounted, takes today’s first-strike requeue and
dedups once the commit lands; a client COMMIT timeout leaves the outcome uncertain (D6): no client timer undoes a
commit in progress. #2765 AC4 is read against this bound. Two subtransactions per envelope (32 at K = 16) stay under
PostgreSQL’s 64-entry per-backend cache, which caps K.
D4. One envelope inside the batch, and the commit phase
Each phase sets both timeouts itself, before its savepoint (SET LOCAL outlives RELEASE and is restored by a
rollback to an earlier savepoint), so no phase inherits another’s; a phase’s fixed-text statements share one
sqlx::raw_sql round trip. Reused from inbox.rs, raised to pub(crate): AttemptCtx, Conflict,
classify_conflict, count_failed_attempt, log_failed_attempt, surface_terminal, handle_collision,
StageClock, resync (from #2770), and invoke_handler, which gains a deadline: Duration parameter.
-
Claim.
SET LOCAL lock_timeout = '50ms'; SET LOCAL statement_timeout = '1s'; SAVEPOINT claim, the claimINSERT … ON CONFLICT (envelope_id) DO NOTHING(received_atandattempt_started_atfrom oneclock_timestamp()), thenclassify_conflict(FOR UPDATE) on a conflict. SQLSTATE55P03,40P01,57014orConflict::Vanished: roll back to and releaseclaim,Deferred(D5).AlreadyDoneis provisionally deduplicated,TerminalUnsurfacedterminal,Collisiona collision (canonical row locked, untouched), each releasingclaim; a fresh claim or aRetrygoes on holdingclaim. -
Handler.
SET LOCAL statement_timeout = '2s'; SET LOCAL lock_timeout = DEFAULT; onRetrytheattempt_started_at = clock_timestamp()restamp;SAVEPOINT attempt;invoke_handler(…, BATCH_HANDLER_DEADLINE). -
Completion. Success: release
attempt,processed_at = clock_timestamp(), releaseclaim. Handler error or tier-1 panic:count_failed_attempt, release both; the count commits with the batch. A batch-budget expiry (the 5 s deadline, a batch statement’s57014, a handler erroris_statement_timeoutaccepts) rolls back to and releasesclaim:Deferred(BatchBudget), uncounted; its solo run gets today’s budgets, where a deadline still counts. -
Resync. A deadline that drops the handler mid-statement leaves that statement’s result owed: sqlx drains it before the next statement and returns its error (
sqlx-postgres0.8.6connection/mod.rs:85-98). Before any rollback,resyncpings until the connection is idle: a database error is the dropped statement’s own and is absorbed; an I/O error or its 3 s bound aborts the batch. Only thenROLLBACK TO SAVEPOINT, whose failure aborts it. -
Commit phase.
SET LOCAL statement_timeout = '1s'; SET LOCAL lock_timeout = '1s', thenCOMMIT, so no envelope’s leftover settings govern deferred work.
Any other error (an unlisted SQLSTATE in the claim savepoint, a statement outside a savepoint, the connection, a client
round-trip timeout) aborts the batch (D6). A second copy of an envelope id is Deferred(DuplicateId) before its claim.
D5. Deferred claims
DeferReason is a closed set: Contended (55P03, 40P01), ClaimTimeout (57014), Vanished, DuplicateId,
BatchBudget. A deferred delivery has no accounting in the batch. It runs solo after settlement through
handle_idempotently, whose claim waits under the 30 s default, by then only on the foreign holder. Two batches
cross-claiming each other’s rows both defer within 50 ms, below the 1 s deadlock_timeout default, so neither is a
deadlock victim; both commit and the solo runs dedup.
D6. Commit, settlement and arbitration
-
Committed. Outcomes stay provisional until
COMMITreturnsOk. Settlement is per delivery (D2 step 4): plain acks first, then each delivery’s post-commit work (surface_terminalfrom the durable row,handle_collision), settle, beat. A stalled DLX confirm (CONFIRM_TIMEOUT, 10 s) delays only later surfacing deliveries, never the heartbeat (the liveness threshold is 120 s). AFaileddelivery climbs its own 2-strike ladder, never its siblings'. A settlement failure tears the session down (#1197); the unsettled redeliver into dedup. -
Failed. A statement error that aborted the transaction, a lost connection, a client timeout, any
COMMITerror (uncertain: the server may have committed) or a tier-2 panic before the commit makes every admitted and deferred verdictArbitrate. The session keeps those deliveries unacked and runs each solo (D2 step 6): its claim arbitrates (a commit that landed dedups; a rolled-back one runs again), and its own outcome takes today’s strike ladder. No nack, strike or marker touches a sibling, and nothing session-local can be lost: no delivery leaves this consumer, so the guarantee holds across consumers and versions. The failed batch’s connection is closed, not returned. This amends #2765’s constraint "left for inbox arbitration (requeue)": arbitration runs here, through the inbox claim. -
Panics. Before the commit: the batch fails, as above. In a delivery’s post-commit work: its effects are durable; the delivery is nacked with requeue and its redelivery dedups. Nothing renders
Eafter the commit.
D7. Failure semantics
| Case | Inside the batch | Batch committed | Batch failed |
|---|---|---|---|
Handler |
stamped processed |
ack |
solo here, runs again |
Handler error, tier-1 panic |
rolled back to |
its own 2-strike ladder |
solo here |
Handler deadline, 2 s statement cap |
resync, rolled back to |
solo after settlement |
solo here |
The count reaches 5 |
counted |
terminal surface, then ack or requeue-durable |
solo here |
Row already processed or failed |
locked |
ack (dedup) |
solo here, dedup |
Row at the cap, unsurfaced |
locked |
terminal surface, then ack or requeue-durable |
solo here |
Identity collision |
canonical row locked, untouched |
ledger row and surface; nack without requeue |
solo here |
Contended or timed-out claim, vanished row, second copy |
rolled back to |
solo after settlement |
solo here |
|
not admitted |
solo |
solo |
Flushed by count or budget |
not claimed |
leads the next round |
leads the next round |
Panic in post-commit work |
durable |
nack with requeue; redelivery dedups |
— |
Crash or session loss |
rolled back if uncommitted |
redelivered solo; dedup |
redelivered solo; runs again |
D8. Per-envelope times and the detection guarantee
-
craig-mq (batch SQL only).
received_at,attempt_started_atandprocessed_attakeclock_timestamp();failed_atkeepsnow()in its own post-commit statement. The single path’s SQL is unchanged. -
craig-security.
store::audit::insert_audit_entrywritestimestamp = clock_timestamp()andstore::archive::insert_ledger_rowarchived_at = clock_timestamp(): the detection windows' own clock, and solo runs reusehandle_idempotentlyas is. -
Detection. A threshold rule counts rows stamped within
window_minutes(W) before each scan; scans run every I seconds and skip missed ticks (detection.rs:76-79). A row stamped at T is visible at its commit, T + d, so a cluster is guaranteed to fire only when its span ≤ W − I − d: some scan then holds every row in its window. Today d is the rest of the row’s attempt (milliseconds); batched, it is the rest of its batch: milliseconds when handlers are fast, at most 19 s of interruptible work, longer only under a WAL stall, as today. Sampling already misses clusters wider than W − I; batching narrows the guarantee by d. U4 documents it and tests both sides; exact sliding-window detection, independent of scan alignment and commit lag, is #2771.
D9. Observability and the transaction-count oracle
-
Per envelope,
StageClockchargesclaim,handler,complete,surface,total;acquireandcommitare batch stages (0 in itsinbox attempt timingsevent, emitted with the confirmed outcome). -
New
metrics::inbox_batch(otel and stub twins):craig_mq_inbox_transactions_total{queue, mode}(batch/single, +1 per successful attempt-transactionBEGIN),craig_mq_inbox_batches_total{queue, outcome}(committed/arbitrated),…batch_envelopes{queue},…_batch_seconds{queue, stage}(acquire,hold,commit),…_batch{flushes,deferrals}_total{queue, reason}; the settle labels gainnack_requeue. The oracle sums the transaction counter for a test’s unique queue through its own OTel → Prometheus bridge (themetrics.rsprecedent), never timestamps orxmin.
D10. Pool and deployment
CRAIG_SECURITY__AUDIT_BATCH_MAX (1–16) is a field of craig-security’s own settings struct, validated at boot; 1
subscribes through subscribe_idempotent. Its default is 16 only if U4’s comparison meets its target, else 1. The
3-connection consumer pool (EVENTS_CONSUMER_POOL_CONNS, lib.rs:464) is unchanged: the batch holds one connection
until COMMIT; post-commit work and solo runs take one at a time. No migration, no deployment barrier: a single-path
replica and a batch contend as any two claimers (D3, D5).
Scope
Order: #2770 → U1 → U2 → U3 → U4, each with its canonical doc page and a CHANGELOG.adoc == Unreleased
entry. This page’s MR adds its nav entry; U2’s MR sets Status In progress.
U1 — docs(adr): amend ADR-062 for an opted-in batched inbox (weight 2, P2-medium, docs/abc-u1-adr-062-batch-amendment, after plan approval)
-
Docs: ADR-062 gains § "#2765 — an opted-in subscriber commits a batch per transaction": the re-decision for
subscribe_idempotent_batchedcallers; D3’s conditional bound, stated for both paths (the WAL flush and unnoticed transport stalls are outside it); local arbitration of a failed batch; D4–D8 in summary; and the rejected alternatives:synchronous_commit = off(a crash after the ack loses acked audit rows), and parallel consumers (group commit does share WAL flushes, but they add connections and lock holders, give up ordering and leave the gain to commit tuning, where a batch amortizes explicitly). -
Gate: merges before U2 starts. Code / Tests: none. CHANGELOG:
=== Changed.
U2 — feat(mq): run a batch of inbox attempts in one transaction (weight 8, P2-medium, feat/abc-u2-inbox-batch, after U1, #2770)
-
Code:
inbox_batch.rs(D1’s types, D3’s constants andadmit, D4–D6’s database side,finish_committed); ininbox.rsthe visibility raises, thedeadlineparameter and thesinglecounter;metrics::inbox_batch. -
Tests (
crates/craig-mq/tests/inbox_batch.rs, a scratch database per test;inbox_tx.rs’s helpers move unchanged to `tests/common/inbox.rs):-
Functional: 8 envelopes commit claims, effects and stamps in one transaction (oracle = 1), stamps distinct and ordered; a processed id dedups; a second copy defers; an
anyhow-wrapped57014defers uncounted through the classifier while a genuineanyhowerror counts. -
Fault injection: a handler error and a tier-1 panic count while siblings commit; the deadline and
pg_sleep(3)under the 2 s cap defer uncounted; drain overlap: a handler startingpg_sleep(3)at 4.9 s is dropped,resyncabsorbs the drained error, it defers and later siblings commit on the same transaction; a poisonedCOMMIT, a terminated backend (fault/pg_terminate.rs) and a pre-commit tier-2 panic each giveArbitratefor all, nothing persisted; at the cap with the DLX unroutable,finish_committedreturnsSurfaceFailed,failed_atNULL. -
Commit phase: a trailing dedup or deferred envelope with 0.5 s of deferred-trigger work commits; with 2 s the commit phase cancels into
Arbitrate, whichever envelope is last. Concurrency: cross-claiming batches both defer, each effect lands once; a foreign claim defers its envelope within 50 ms (+ 200 ms tolerance), siblings commit. -
Invariant (AC4),
crates/craig-mq/tests/invariants/: 16 envelopes sleeping 2 s flush with 3 admitted while a duplicate claimer of the first waits under the interruptible bound and dedups; a commit-phase stall cancels within the bound and the waiter dedups or processes after arbitration; a transport stall (toxiproxy viafault/pg_transport.rs,#[ignore = "requires devstack"]) hits the clientCOMMITtimeout and arbitration dedups or processes; aproptestkeeps any simulated interruptible hold ≤BATCH_HOLD_BUDGET. -
Recovery: after each abort the same pool’s next batch commits. Unit:
BatchPolicyrefuses 0 and 17.
-
-
Docs:
shared-crates.adoc§ craig-mq. CHANGELOG:=== Added. -
Erratum (2026-10-26): finish_committed returns InboxError<RenderedError> (the pre-commit text), and BatchReport and Committed carry no E, so nothing renders E after the commit (D6).
-
Erratum (2026-10-26): a failed batch’s transaction is dropped, not its connection closed; sqlx’s rollback-on-drop and release ping decide reuse, as on the single path (D6 corrected).
-
Erratum (2026-10-26): a handler that reaches
BATCH_HANDLER_DEADLINEleaves the hold pastADMIT_CUTOFF, so the envelopes after it areCarried; the drain-overlap and deadline tests assert that the sibling claimed before it commits on the same transaction. -
Erratum (2026-10-26): the commit phase also runs SET CONSTRAINTS ALL IMMEDIATE — PostgreSQL disables statement_timeout before commit processing, so deferred constraint work at COMMIT would otherwise be unbounded (D4 commit phase corrected; the single path’s same gap is #2775).
U3 — feat(mq): opt a subscription into batched inbox claims (weight 5, P2-medium, feat/abc-u3-batched-subscription, after U2)
-
Code:
subscribe_idempotent_batched,supervise_batched,subscriber_batch.rs(D2, D6), the helper raises,SettleOutcome::NackRequeue, andfault-injectionhooks (thearm_stage_faultprecedent):arm_batch_settle_faultends the session after the commit with nothing settled;arm_finish_panicpanics in one delivery’s post-commit work. -
Tests (
crates/craig-mq/tests/inbox_batch_subscriber.rs, a scratch vhost and database per test; a burst is made deliverable at once by subscribing, cancelling, publishing, resubscribing):-
Functional: 64 envelopes yield 64 effects, each once, in fewer than 64 transactions.
-
Arbitration: a poisoned
COMMITruns every delivery solo on the same consumer, none nacked,error_count0, and with a second batched and asubscribe_idempotentconsumer on the queue no member reaches either; a tier-2 panicking envelope’s batch arbitrates and its own solo run climbs its own ladder. -
Fault injection: a failing envelope climbs its own ladder while each sibling runs once; 15 at-cap envelopes with stalled confirms (toxiproxy,
fault/mq_transport.rs) and a healthy sibling: the sibling is acked first, heartbeat gaps stay under 120 s;arm_finish_panicleaves durable effects and the redelivery dedups; the settle fault rebuilds the session into dedup; a redelivered delivery never joins a batch; each carried delivery settles once. -
Recovery / shutdown:
transport_faults.rsandsubscriber_shutdown.rsgain the batched legs. Unit: the labels.
-
-
Docs:
shared-crates.adoc§ craig-mq. CHANGELOG:=== Added. -
Erratum (2026-10-26): the stalled-confirms test uses 3 at-cap envelopes (15 × the 10 s confirm timeout exceeds the test runner’s 120 s kill); per-delivery beats are asserted directly.
-
Erratum (2026-10-26): a post-commit panic’s redelivery re-claims the durable row — a processed one dedups, a counted failure retries, a terminal or collision row re-runs its surface or record (D6/D7 corrected);
U4 — fix(security): batch the audit subscriber’s inbox claims so one commit carries many envelopes (#2765; weight 5, P2-medium, fix/abc-u4-audit-batch, after U3)
-
Code: the
AUDIT_BATCH_MAXsetting (D10); apub(crate) subscribe_auditpicking the batched or single subscription, called byspawn_audit_subscriberand the C14 audit rig inlib.rs’s test module; D8’s two inserts; the probe (`services/craig-security/examples/inbox_latency_probe/) gains--path single|batchedand--batch-max K, driving a published burst through the real audit subscriber on a scratch vhost. -
Tests (that test module, on a scratch vhost):
-
Burst (AC2): 64 distinct
test.audit_probeenvelopes delivered at once yield exactly 64 audit rows and 64 processed claims witherror_count0, in fewer than 64 transactions. -
Times (AC5): timestamps distinct, increasing in
attempt_started_atorder, each ≥ its claim’s; twohandle_inbound_eventcalls in one transaction,pg_sleep(0.01)apart, store distinct timestamps. -
Detection: with a threshold-2 rule, a row inserted earlier and a row whose batch commit a slow sibling delays by d, a scan after the commit fires when the rows' span ≤ W − I − d, and the documented miss holds when the older row leaves the window before the commit.
-
Setting: 0 and 17 refuse boot; 1 selects the single path. The C14 disconnect legs run batched, unchanged. AC6: craig-cases'
tests/api/ive_determination.rsandperson_identifiers.rsand craig-composition’stests/api/act_events.rsstay unedited.
-
-
Measurement (the default’s gate):
cargo xtask diag inbox-latency --path batched --batch-max 16against--batch-max 1, phase A (baseline) and B (WAL load), three runs of 2000 envelopes each: throughput, drain time, audit lag p50/p99, batch occupancy, deferrals, arbitrations, commit p50/p99. Default 16 when phase B drains ≥ 3× faster and phase A runs ≥ 0.9×; otherwise default 1, the MR saysRelates to #2765, and the figures go on #2765 and an erratum. -
Docs:
data-model-security.adoc(the timestamps; the detection guarantee atwindow_minutes),configuration-reference.adoc. CHANGELOG:=== Changed; Ops note: no migration or barrier, the setting, metrics. -
Close-out: Status
Done (<date>) — !<U4>,git mvintoplans/archive/, the nav entry, an archive row,cargo xtask plan-lint --done. -
Erratum (2026-10-26): subscribe_audit and the timeout classifier are #[doc(hidden)] pub, not pub(crate), so the inbox-latency probe (an example) drives the real subscriber.
-
Erratum (2026-10-26): CRAIG_SECURITY__AUDIT_BATCH_MAX is read directly from the environment at boot by a pure, typed parse_audit_batch_max (the DETECTION_INTERVAL_SECS precedent, without its silent default), not a settings-struct field: craig-security has no settings of its own outside the shared ServiceSettings; this supersedes D10’s settings-struct wording.
-
Erratum (2026-10-26): the comparison missed its target — under phase B, K = 16 (
--path batched --batch-max 16) drained 2.83× faster than K = 1 (--path single), median of three 1832 ms against 5182 ms for 2000 envelopes, where 3× was required; phase A ran 1.99× (1133 ms against 2259 ms) — so the default is 1, the MR relates to #2765 rather than closing it, and the figures go on #2765. -
Erratum (2026-10-26): the detection guarantee is strict (span < W − I − d) and I is the effective interval between completed scans (a skipped tick lengthens it); the tests prove an interior fire and an expiry miss, not the literal boundary (D8 qualified).
-
Erratum (2026-11-12): the default is 16. The maintainer ruled (2026-11-06) that the default be re-judged under sustained WAL pressure; re-measured with three runs per cell, K = 16 drained 5.62× faster than K = 1 under WAL load and 2.28× at baseline over 20,000 envelopes (medians 21272 ms against 119653 ms, and 9155 ms against 20908 ms), which meets the 3× and 0.9× target. Over the 2,000 envelopes this unit names, a run that mostly ends before the load’s checkpoint starts, it measured 1.84× and 2.28×; the maintainer judged the default on the longer cell. Figures are on #2765.
Out of scope
-
Other consumers (each opts in by its own issue); parallel sessions; a larger
PREFETCH; the DLQ subscriber; #2699’s cause and WAL settings; the single path beyond #2770; exact detection (#2771); #1214.
Risks
-
Tighter bounds. A statement over 2 s or a handler over 5 s defers and re-runs solo on today’s budgets.
-
Shutdown mid-arbitration. Unsettled deliveries redeliver with
redeliveredset, as today’s prefetched ones do; a later failure dead-letters one strike early, and admin replay recovers. -
Commit-only gain. Batching amortizes the commit fsync, not WAL-insert waits; U4’s measurement decides the default.