GeezerVison is showing github.com — id(sync): PR #1433 collect_batch lets refused arrivals grow a batch without bound — no total cap, grace restarts on every arrival · Issue #1537 · developing-today/code
id(sync): PR #1433 collect_batch lets refused arrivals grow a batch without bound — no total cap, grace restarts on every arrival #1537DescriptionFinding
PR #1433's new collect_batch (pkgs/id/src/log_sync.rs) caps a batch only by its header count, but stores every arrival in the batch Vec and restarts the batch grace on every arrival — including Arrival::Refused. A peer that keeps sending refused arrivals inside the grace window can therefore keep one batch open indefinitely: the Vec grows without bound, no write transaction ever commits, and the refused tally is never recorded.
Filed by pr-diff-review-b (lane B) from reviewing PR #1433. Refs #241 (the PR's parent issue).
Evidence
- PR: fix(id): coalesce LogSync ingest batches and restart batch grace on each arrival (#241) #1433 — OPEN, head
0c80543f842ecee1eab5da56ba910f1aed472877
- PR head
pkgs/id/src/log_sync.rs:454 — fn collect_batch(first: Arrival, arrivals: &mut mpsc::Receiver<Arrival>) -> Vec<Arrival>
- PR head
pkgs/id/src/log_sync.rs:461-468 — headers increments only for Arrival::Header(_); batch.push(arrival) runs for every arrival; the only break is if headers >= INGEST_BATCH { break; } (INGEST_BATCH = 256 headers)
- PR head
pkgs/id/src/log_sync.rs:470-476 — on every received arrival the grace is reset (grace_end = None), so the 5 ms BATCH_GRACE (:73) is an idle timeout that a steady refused stream never lets expire
- What a
Refused arrival is (current main 3b559045, pkgs/id/src/log_sync.rs ~:349-356): an Operation message that carries a body — "Events carry no body here, and a body is not stored, so a body is refused." It is entirely peer-controlled and costs the peer one frame per arrival.
- Behaviour on current main that the PR replaces:
ingest_arrivals counts a refusal immediately (tally.refused += 1), never stores it in a Vec, and collects a batch with non-blocking try_recv only — a refused-heavy stream cannot accumulate or stall a batch.
So on the PR head: body-carrying operations spaced <5 ms apart keep collect_batch looping forever (headers stays 0, the cap never fires, disconnect is the only exit), the batch Vec grows by one element per frame for as long as the peer keeps sending, and the ingest worker (spawn_blocking, one per session) makes no progress — no commit, no tally — for the whole time.
The four new batch tests in the PR exercise only Header arrivals, so this mix is unpinned.
Why it matters
LogSync ingest is a network-facing path: the peer pacing the arrivals is not necessarily a well-behaved client. One misbehaving or buggy peer can pin a blocking worker thread and grow host memory linearly with frames sent, for the duration of a session, instead of being counted-and-refused as on main today. It is also a silent stall: nothing is committed and no error surfaces while it happens.
Acceptance criteria
-
collect_batch is bounded in total arrivals and/or wall time regardless of the header/refused mix (e.g. refusals count toward a cap, or are tallied and dropped during collection as on main, or a maximum batch duration is enforced) — the chosen bound is named in the doc comment, replacing the current "refusals do not count towards the cap, as before" wording if it no longer describes the whole story
- New regression test: a stream of
Arrival::Refused paced inside the grace (and/or more refusals than INGEST_BATCH) terminates the batch at the bound, and the headers collected alongside are still handed to the store
- The PR's existing four batch tests (paced coalescing, grace restart, lone arrival, full-batch cap) still pass
Activitydeveloping-today commented on Oct 28, 2026 dezren39 commented on Oct 28, 2026 dezren39 commented on Oct 28, 2026 dezren39 commented on Oct 28, 2026 dezren39 commented on Oct 28, 2026
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|