Skip to content

fix(feeders): readsb lossy Beast-output warning reads degraded, not down (#369) - #372

Merged
stevenpickles merged 4 commits into
devfrom
127-beast-output-lossy-lines
Nov 30, 2026
Merged

stevenpickles merged 4 commits into
devfrom
127-beast-output-lossy-lines

Conversation

@stevenpickles

@stevenpickles stevenpickles commented Nov 30, 2026 •

Copy link
Copy Markdown
Owner

Summary

Slice 127. readsb's periodic Bad connection, dropping data (connection lost N% of data) (suppress msg for 300 s) warning is logged on an open Beast output. beast_connected() treated every line that was not Connection established as a disconnect. So after a restart, the first read showed both ultrafeeder feeds down, and they stayed that way until readsb next reconnected, which can take days (#369).

What readsb actually logs (net_io.c, wiedehopf/readsb bc57f2ddd83016e5628f63012eea1a51155623a5, 2026-11-27; this is also the newest commit touching net_io.c as of today)

  • established: checkServiceConnected: <descr>: Connection established: <host>[ (<ip>)] port <n>[ (sent UUID)]
  • closed (each is followed by modesCloseClient or the socket being closed):
    • readClient: Remote server disconnected: <host> port <n> (fd …)
    • flushClient: Send Error: <err>: …, Couldn't send any data for 5.00s (Insufficient bandwidth?): disconnecting: …, send() weirdness: …
    • serviceReconnectCallback: No data or heartbeat received for N seconds, reconnecting: …
    • readClient: Socket Error: … (--debug net only)
    • connect attempts: Connection to <host>[ (<ip>)] port <n> failed: … / failed (k): … / timed out. / failed k times, suppressing most error messages until connection succeeds
  • lossy: dropHalfUntil: <host> port <n>: Bad connection, dropping data (connection lost %4.1f%% of data) (suppress msg for %d s). The connection stays open, and readsb drops every other chunk for a while. dropHalfUntil is called on a write shortfall (flushClient/flushWrites, 2 s) and when the remote sends a W S reduce command (net_io.c:4590). N is cumulative since the connection opened: 100 - bytesSent/bytesFromWriter*100, and both counters are per-client fields zeroed by the memset in createSocketClient. The line is printed when dropping starts, at most once every 300 s, and never in the connection's first 10 s.

Rulings

  1. Only state lines set state. classify_beast_line returns established / closed / lossy / unrecognised. Only established and closed lines set connected and since_ms. A first read with no state line in the tail gives connected=None, the existing semantics (test: lossy-only tail).
  2. Lossy degrades, never downs. N is cumulative per connection, so ≥ 1.0% is a real share of that connection's output. The feed is degraded with "ADS-B output dropping data (N% lost since it connected)" when the newest lossy line of the current connection is ≤ 15 min old (LOSSY_RECENT_MS) and N ≥ 1.0 (LOSSY_DEGRADED_PCT). Otherwise it stays up. detail.adsb_out_loss_pct carries N whenever the output is connected and a loss figure is known. A close, or a newer established line, drops the previous connection's figure. adsb_out.connected stays true and last_data_sent_ms is unchanged. The AdsbOutStatus API shape and the stored metrics are unchanged. With MLAT also unwell, the state is still degraded and both reasons are joined in the message.
  3. Unrecognised lines. They keep the verdict and are logged at warning as feeder_adsb_out_unrecognised_line with the text and timestamp. Lines are deduplicated on (text, ts) against the previous read, which covers the 5 s overlap. Repeats of the same line within one read are deduplicated too. The Feeders: ADS-B Exchange and AeroDataBox shown offline for hours while both feeds were up (silent ultrafeeder log) #276 silent-log rule is untouched. feeder_adsb_out_transition now carries kind and is also emitted for lossy lines, with loss_pct.
  4. Docs. There is no FEEDERS.md. The three kinds are documented in the module docstring and in docs/API.md (feeder states, adsb_out). ADR-0017 (l.34) and docs/design/077-feeders-page.md (l.24) each get a dated amendment note (2026-11-30, slice 127, Feeders: readsb 'Bad connection, dropping data' warning marks an open Beast output as down #369).

Known limitation (documented at the threshold: the constant, the module docstring and API.md): N is a lifetime share of the connection, not a current rate. On a long-lived connection, a fresh severe episode may never reach 1.0% and reads up; ten minutes of half-drop on a two-day connection is about 0.2%. A connection that lost data early reads degraded for 15 min on any later 2 s hiccup. A young connection overstates its loss.

Tests

  • New fixture backend/tests/feeders/fixtures/readsb_beast_lines.tsv has one row per readsb wording, cited to the commit above. It includes the reference install's verbatim 0.0% line. A parametrized test checks that each row is matched and classified by its kind.
  • Reference-install replay at 2026-11-30T13:25:39Z (established on 11-28, a 0.0% warning that evening): both feeds read up, with since set to the established line's time and adsb_out_loss_pct = 0.0. This holds for two fresh probes, before and after a restart. The state is never down, so no "Feed offline" self-alert (which only down raises).
  • disconnect → established → lossy (12.5%, a minute old): degraded, then up once the line is 15 minutes old. Also covered: below the threshold stays up, lossy with MLAT unwell, a loss figure not outliving its connection (closed reads down with no loss detail; reopened reads up), and an unrecognised line warned once across the overlap without moving the state.
  • The existing fixture ultrafeeder.log used an invented Connection refused: <host> … port line. It now uses readsb's real Connection to <host> (ip) port 30004 failed (1): 111 (Connection refused).

Run locally:

  • uv run pytest tests/feeders -q --no-cov: 203 passed
  • uv run ruff check .: clean; uv run ruff format --check .: clean; uv run mypy: no issues (577 files)

Discovered (not in scope)

  • readsb's Name resolution for <host> failed line has no port, so the matcher never sees it. A feed whose DNS fails before any connect attempt keeps its previous verdict until a Connection to … failed line appears. This is unchanged behaviour.

Closes #369

🤖 Generated with Claude Code

https://claude.ai/code/session_01JFZvpNYnicPHv6pjHTVK2f

stevenpickles and others added 2 commits November 30, 2026 08:50
…ot down

readsb's "Bad connection, dropping data (connection lost N% of data)"
warning is logged on an open Beast output, but beast_connected() took every
non-"Connection established" line as a disconnect, so a first read after a
restart reported both ultrafeeder feeds down for days (#369).

Matched lines are now classified from readsb's own wording (net_io.c at
wiedehopf/readsb bc57f2dd): established, closed (remote disconnect, send
error/timeout, heartbeat reconnect, failed or timed-out connect), lossy, or
unrecognised. Only established/closed lines set connected and since; a
lossy line reports N (cumulative since the connection opened) as
detail.adsb_out_loss_pct and degrades the feed while it is at most 15 min
old with N >= 1.0%; an unrecognised line keeps the verdict and is warned
about once.

Refs #369

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JFZvpNYnicPHv6pjHTVK2f
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JFZvpNYnicPHv6pjHTVK2f
stevenpickles and others added 2 commits November 30, 2026 08:56
…ds; state the cumulative-N limit

Per Fable review of PR #372: dated amendment notes (2026-11-30, slice 127,
#369) in ADR-0017 and docs/design/077-feeders-page.md; the cumulative-N
limitation stated at the threshold (constant, module docstring, API.md);
the degraded message now reads 'N% lost since it connected'; the lossy line's
second source (a remote W S reduce command) noted; unrecognised lines
deduplicated within one read as well as across the overlap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JFZvpNYnicPHv6pjHTVK2f
@stevenpickles
stevenpickles merged commit a9e47e7 into dev Nov 30, 2026
14 checks passed
@stevenpickles
stevenpickles deleted the 127-beast-output-lossy-lines branch November 30, 2026 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feeders: readsb 'Bad connection, dropping data' warning marks an open Beast output as down

1 participant