Skip to content

the destination Write has no deadline and runs on the poll goroutine — a delivery-path stall freezes COLLECTION (S2) #345

Done

Description

@randomizedcoder

Found by the red-team harness (docs/redteam-plan.md row rt-11-5; findings.md 20261126T014816-1935fd894-1334095).

Mechanism

flushEnvelope (pkg/xtcp/poller.go:150) runs on the poll goroutine and calls dest.Send synchronously; tcpDest.Send (pkg/xtcp/destinations_tcp.go:47) is a blocking conn.Write with no write deadline. A delivery-path stall (ARP blackhole, wedged switch, stalled peer) therefore walks straight up the poll path:

  1. the segments stop landing — delivery dies instantly, silently;
  2. the Writes keep succeeding locally while SO_SNDBUF absorbs envelopes (~10-30 s of them);
  3. the buffer fills → the Write blocks → the whole poller freezes for the TCP retransmit window — no polls, no error counters, nothing delivered, metrics 200;
  4. the window closes (default tcp_retries2=15 ≈ 15.4 min) → the Write errors → polls resume, but delivery is permanently dead (no reconnect, tcpDest dials once and never reconnects — a receiver restart is a permanent blind #339).

Measured (rt-11-5, CONFIRMED 16/16)

  • the freeze: polls frozen over 14 s at tcp_retries2=8, zero error counters, scrape 200 the whole time — fully silent;
  • de-poison mid-window: the buffered envelopes drain, the catcher catches up (1667 lines/6 s), zero error counters, zero loss — the blind is latency, not loss;
  • the window closed: counters light up after the silent gap, polls resume, delivery stays dead until a daemon restart.

A privileged co-tenant (CAP_NET_RAW, sibling on the bridge) can hold this state indefinitely with a 200 ms gratuitous-ARP loop; a wedged broker or a switch does it without an attacker.

Fix directions

  • SetWriteDeadline on the dest conn (a bound, not 15 min), and/or
  • decouple the flush from the poll goroutine (a queue + worker, like the s3 queue's shape) so a stalled sink delays delivery, not collection.

Expectation flip

When fixed, rt-11-5's phase-1 asserts flip in the same PR (no freeze: polls continue through the stall).

Activity

  1. added
    bug
    on Nov 26, 2026
  2. randomizedcoder commented on Nov 26, 2026

    @randomizedcoder
    OwnerAuthor

    Fixed by PR #348 (with the expectation flip on the row that pinned it).

    The tcp destination is now a bounded queue + worker, mirroring the s3parquet queue's shape:

    • Send never blocks — flushEnvelope hands the marshaled envelope to a bounded envelopeQueue (depth 16 / -tcpQueueDepth, bytes -tcpMaxBufferedBytes, oldest-first eviction, counted in xtcp_tcp_dropped_total), so a wedged sink can never stall the poller again. The freeze is structurally gone.
    • Every write AND dial carries SetWriteDeadline — tcp_write_timeout (config field 120, validate-bounded to [1s, 1h], default 30 s, -tcpWriteTimeout / TCP_WRITE_TIMEOUT), so a blackholed route costs the timeout, not the ~15.4-min retransmit window.
    • A failed write reconnects under full-jitter backoff (the cap derived like the s3 ladder: clamp(poll_frequency/10, 1s, 1h)) with 3 attempts per envelope, then drop-and-count — also fixes tcpDest dials once and never reconnects — a receiver restart is a permanent blind #339's permanent blind.

    Measured by the same attack that pinned the bug (rt-11-5, MITIGATED 18/18, evidence 20261126T111738-209ab068a-1688938, XTCP2_TCP_WRITE_TIMEOUT=5s): polls keep issuing through the stall (25→47 over 32 s; pre-fix the poller froze for the whole window with zero counters), the blind is visible and counted while dark (Write/error=9, Dial/error=8, xtcp_tcp_dropped_total=3, scrape 200), and de-poison heals delivery with no daemon restart (reconnects=1, 2498 lines/6 s; second cycle repeats the whole arc).

  3. randomizedcoder commented on Nov 27, 2026

    @randomizedcoder
    OwnerAuthor

    Correction: the fix landed in PR #352 (not #348 as referenced above — that number went to an unrelated PR in the meantime). The branch is redteam/tcp-dest-queue-worker, commit 55f387519.

  4. added a commit that references this issue on Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions