~ knotless Search/
↑↓ move↵ open⇧↵ all results

zat.dev/zlay

atproto relay in zig · mirror of https://tangled.org/zat.dev/zlay

0
0
268 lines · 15.7 KB Raw History

handoff: deploy zlay main 205cf7f and move lightrail back (2026-10-18)

Lightrail recovery follow-up (2026-10-18, verified)

Zlay cd1b2cc / ReleaseSafe-zio-cd1b2cc deployed successfully at ~19:02Z, pod zlay-56b567db8d-b8nxx. The shared live/replay frame normalization now inserts rebase:false when absent, preserving explicit flags and signed CAR bytes. The subscribeRepos lexicon still requires this deprecated field. Linux fmt, tests and zio build passed; ten live plus ten retained replay commits all carried boolean rebase after rollout. Exact offending upstream PDS for the earlier omission was not identified.

Lightrail had two bugs: 20-second eviction removed unfinished sequences from cursor/backpressure accounting without removing queued work; HashMap-order scheduling starved old pending DIDs behind newer work. Source fixes plus bounded identity HTTP waits, replay deduplication and an already-applied revision fast path are preserved in relay's indigo/deploy/lightrail-recovery.patch. 183 Rust library tests pass; the scheduler regression fails on old code.

Final current image: atcr.io/zat.dev/lightrail:recovery-2ba85f0, digest sha256:8aa6a8b8496bd13826bb2581e764448a19ad0fb4dc017f9f706e0d5f4f262b0c. Current pod lightrail-7bc4745875-lnv98 has 64 workers, a 2000-event bound, and no forced rewind. It resumed saved cursor 4017642270 contiguously at 19:15:06Z.

Live catch-up verified from 19:29:26Z through 19:32:34Z (189 seconds): all 5 samples have zero queued firehose events, with 0–9 outstanding. Completed sequence advanced from 4020731593 to 4020814860; live head advanced to 4020816122. Direct-head comparisons include sequential HTTP/SSH sampling and the one-second metric refresh, so their ~1–2k difference is not an atomic latency measurement. Current pod has zero restarts. CPU settled around 0.6 cores after replay; memory was ~3.8 GiB, below its 6 GiB limit. Public collection listing returned HTTP 200 and valid repositories. Zlay health remains 200, with no broadcast waits, slow-consumer kicks, or broadcast/CPU alerts.

No missing-rebase or other firehose decode errors appeared. One independent worker error occurred at 19:26:51Z: sequence 4020164017, DID did:plc:zwggkux4zv6b3pgsahaoa4mz, malformed MST layer while walking a CAR. This is not a claim of error-free repository recovery. Separate resync depth is 42,054, down from 43,078 after live catch-up; slow PDS requests and historical repository gaps remain. Older pruned event history before 16:53:02Z is not proven recovered.

Recovery started from oldest retained sequence 4016461825 (16:53:02Z). Earlier cursor 4010666018 returned OutdatedCursor, so full earlier history cannot be established. Repository resync work remains a separate backlog. Detailed evidence lives in relay docs/incidents/2026-10-18-lightrail-recovery/.

Final observation (2026-10-18, 18:40Z)

  • Observed the final ReleaseSafe-zio-e5ecb5e deployment from 17:34Z through 18:39Z (65 minutes). Zlay remains ready, zero restarts, public health 200. Across 132 Prometheus samples at 30s steps, sequence rate stayed 279.5–797.1/s and CPU 0.263–0.762 cores. Slow-consumer kicks and broadcast-queue waits remained zero; no broadcast/CPU alerts appeared.
  • Replay-buffer wait count rose from 0 to 373,185; replay is backpressured, so this is not a zero-wait outcome. Final sequence was 4,019,391,597. Two final 500-repo pages returned in 0.652/0.657s, complete and disjoint; sampled latest-commit/listRepos CIDs matched at the same revision. Earlier CAR hashing established signed-commit semantics; it was not repeated as a stress probe during observation.
  • Known signed-commit heads reached 44,365, separately from roughly 7.43 million legacy rows omitted until verified activity supplies a head. The sparse migration limitation remains.
  • Relay eval OOM was fixed independently (0348fa5, explicit libc application allocator under Zig 0.17 ReleaseSafe). Full eval run 10466 succeeded at 179.8 MiB peak and 99.9297% zlay coverage. Scheduled run 10467 saved at 18:36:44Z also measured 99.9201%. The old 50.74% sample was interrupted by rollout and is not the current coverage.
  • Lightrail recovery remains incomplete. Restart count stayed at its baseline of 1. Reconnection was confirmed at 17:34:52Z. The worker queue grew to 261,832 at 18:08Z, fell to 94,593 at 18:24Z, then rose to 166,712 at 18:40Z. Six workers remain occupied; memory was 4,581 MiB. No caught-up claim. The actual-queue/backpressure defect and resync retries recorded in relay's ops changelog remain unresolved.
  • Retained pod logs include one firehose message decode error; skipping frame at 18:38:32Z: DAG-CBOR missing field rebase. Cause/impact beyond that skipped frame is unverified. The requested 65-minute log read only returned logs beginning 18:34:35Z due to retention, so it cannot establish an error-free hour. No additional restart required previous-log capture.
  • Outcome: zlay availability, throughput, pagination and coverage checks passed; end-to-end lightrail recovery did not. This fixed observation is complete and its automation is stopped. Evidence in relay repo: docs/incidents/2026-10-18-zlay-deploy/final-observation/.

Previous checkpoint (2026-10-18, 17:35Z)

  • Production is ReleaseSafe-zio-e5ecb5e, available at 17:33:55Z. Build metric confirms the SHA; public health is 200 and pod zlay-586b79766-rtm89 has zero restarts.
  • Review against Hydrant/Indigo found a further semantic error: API heads were MST-root CIDs. 522c2dd adds separate verified commit-CID storage and fixes listRepos and getLatestCommit across both ingest paths. e5ecb5e bounds both join keys for efficient sparse pagination.
  • All 164 tests passed against disposable PostgreSQL (including migration and signed-commit API regressions), and the zio build/format gates passed. Source in the remote test worktree matched the deployed commit exactly. Normal build-run tests skip DB cases; the compiled binary was run with DATABASE_URL to execute all 164. Repository CI is not configured.
  • Live final-deployment verification hashed CAR commit blocks and matched four stable DID/revision pairs against both API endpoints, excluding their distinct MST CIDs. Two pages at limits 1/500/1000 passed under one second each. Evidence is in relay's incident commit-cid/ directory.
  • Coverage limitation: old signed-commit CIDs were never persisted. About 7.43 million legacy rows keep their revision/MST state, but are omitted until verified commits/syncs populate the new field. Known heads reached 4,231 at 17:34–17:35Z. Historical backfill is separate work; see docs/operations/deployment.md for migration and rollback details.
  • A Discord 503 alert coincided with the rollout's Recreate gap and 60s readiness delay. Public 200 was verified after availability at 17:33:55Z. Announce this downtime before future deploys.
  • The final one-hour observation now runs 17:34–18:34Z or longer. Lightrail's baseline remains restart count 1, and catch-up is not proven. Latest final-pod sample: ~254 seq/s, ~0.67 CPU cores, zero queue waits, zero slow-consumer kicks, no broadcast/CPU alerts. The heartbeat will record the full-window outcome separately; do not claim that it passed.

Previous checkpoint (2026-10-18, 17:00Z)

  • Production is now ReleaseSafe-zio-9bb472e. The original 205cf7f replay fix passed a cloud-hosted 911s probe: 878,882 frames, ten 60s stalls, zero duplicates/reorders/gaps/errors, and replay-to-live handoff. Stalls were every 30s of reading so the first stall happened during replay (cloud replay caught up before the original 90s delay).
  • Lightrail was switched back to zlay, committed/pushed in relay 4fe9195. Its 30-minute clean exit reproduced and is explained: listRepos?limit=500 overflowed zlay's fixed 64 KiB writer, returned HTTP 200 with an empty body, and exhausted lightrail's 60 × 30s backfill retries. At 16:52:18Z it logged the exhausted retry budget, backfill ended without finishing, exiting, and Some(Ok(Ok(()))).
  • f60d891 replaced the fixed writer and fixed limit-1 pagination; 9bb472e excludes accounts lacking a complete repository head/revision. Without the second fix, lightrail rejected empty TIDs in the response. Full zig build test, zig build -Dbackend=zio, and formatting passed. Live two-page checks at limits 1, 500, and 1000 now pass with complete fields and no overlap. Four regression tests cover page size, pagination, incomplete commits, and allocation-failure cleanup.
  • Zig 0.17 cached an old Git SHA in build configuration. Relay's remote recipe now passes --cache-poison=poisoned; the running build metric was verified as 9bb472e, matching the deployed image.
  • One-hour observation remains pending. Observe 17:00–18:00Z or longer. Lightrail pod lightrail-76f658d845-8qrwv, started 16:52:20Z, has restart count 1 from the failure above; any additional restart is new. It reconnected to the corrected relay at 17:00:01Z. Replay is still behind; do not equate process uptime with a current index. Its worker stall evictions remove entries from the backpressure counter without removing queued work, so watch queue size and memory too.
  • Thread heartbeat verify-zlay-and-lightrail-recovery checks every 15m. After the full window, capture the outcome, update this handoff and the relay incident/changelog, commit/push, and pause the heartbeat.
  • Evidence is in relay docs/incidents/2026-10-18-zlay-deploy/; additional scratch and full logs are in /tmp/zlay-deploy-205cf7f/ on the Mac. Prometheus forward used local port 19090. The old pod watch may expire; reopen it as needed. Heavy probes belong on a cloud host, not heavypad (the Stream runbook identifies heavypad as a home-LAN machine).
  • Separate Coral warning: fresh cloud probes confirmed relay1.us-east at ~3 frames/s while west and zlay delivered ~420–445/s. Stream uses east directly. It recovered without intervention; not caused by zlay.
  • Follow-ups not established by the probe: control-frame handling during deep replay (probe ping deadline is disabled), lightrail catching up, and its saved listHosts cursor rejected by zlay. The backport branch is retained; do not delete it merely because this checkpoint exists.

Resume checkpoint (2026-10-18, 15:22Z)

  • Deployed: ReleaseSafe-zio-205cf7f, built remotely with Zig 0.17.0, imported and pinned in containerd. Rollout succeeded; public health is ok and relay_build_info reports 205cf7f. No need to deploy again.
  • Added 168.119.156.18 to the existing waow SSH host stanza on the Mac.
  • Verification incomplete: the first heavypad probe hit its default WebSocket ping timeout after about 40s of ordered replay. The probe now sets ping_timeout=None on the replay connection, since the intentional 60s stalls can delay pong processing beyond the default 20s deadline. A real local WebSocket regression test fails with the old probe and passes with the change (uv run scripts/test_zlay_slow_consumer.py).
  • The rerun completed one 60s stall and resumed replay, with zero duplicates, reorders, gaps, or error frames through its last 190s report. Seq continued advancing (403–571/s in sampled windows), CPU 0.33–0.58 cores, replay waits rose, slow-consumer kicks and broadcast-queue waits stayed zero. This is partial evidence, not a completed 900s pass or a verified live handoff.
  • Stopped the probe deliberately before Nate's Mac went offline for his commute. No stress workload remains running. Lightrail still subscribes to relay1; do not switch it until the full probe passes.
  • Logs and metric snapshots are in /tmp/zlay-deploy-205cf7f/ on the Mac; the remote probe log is /tmp/zlay-probe-205cf7f.log on heavypad.
  • Resume at step 2, running the updated probe on heavypad (uv is ~/.local/bin/uv, absent from noninteractive PATH), with monitoring on the Mac. Then perform step 3 and the full hour of observation.
  • Follow-up limitation: zlay calls replay inside Handler.afterInit; websocket's connection handler calls afterInit before readLoop. The initial timeout therefore also warrants investigation of control frame handling during deep replay. Disabling the probe deadline does not prove heartbeat compatibility.

The original plan and pre-deploy state follow.

Context: ~/tangled.org/zzstoatzz.io/relay/docs/incidents/2026-10-18-zlay-replay-wedge.md (incident, mechanism, fix) and the 2026-10-18 entries in that repo's docs/ops-changelog.md. Everything below is ready; only the deploy and the verification remain. Production is still ReleaseSafe-zio-35fae9a (zig 0.16).

1. deploy

From ~/tangled.org/zzstoatzz.io/relay:

just zlay publish-remote ReleaseSafe 205cf7f zio
  • ssh: the node is root@168.119.156.18, key ~/.ssh/waow_ed25519. It is not in ~/.ssh/config yet; add it to the existing waow Host line, or the recipe's plain ssh root@IP fails with publickey.
  • the server already has zig 0.17.0 as /usr/local/bin/zig and /opt/zlay/zig-pkg/ seeded with every dependency at the right hashes (tangled's archive endpoint 429s under bursts; an N-V-… directory in zig-pkg means a rejected fetch — delete it and retry, or rsync a workstation's verified zig-pkg/).
  • the recipe builds detached and follows /tmp/zlay-deploy.log; reattach with just zlay deploy-logs. ReleaseSafe + rocksdb takes a while.
  • rollback is one command, the old image is pinned in containerd: kubectl -n zlay set image deployment/zlay main=atcr.io/zzstoatzz.io/zlay:ReleaseSafe-zio-35fae9a

2. verify the fix under the failure condition

Watch (KUBECONFIG=zlay/kubeconfig.yaml, Prometheus via kubectl -n monitoring port-forward svc/kube-prometheus-stack-prometheus 9090): rate(relay_seq[1m]), zlay container CPU, relay_consumers_active, relay_slow_consumers_total, and the new relay_broadcast_queue_full_waits_total, relay_persist_order_waits_total, relay_replay_buffer_waits_total. Health: relay_build_info{git_sha="205cf7f"}.

Then run the probe, which is the 2026-10-18 condition on purpose:

scripts/zlay-slow-consumer --relay wss://zlay.waow.tech --behind 500000 --duration 900 --stall-every 90 --stall-for 60

Pass criteria: seq keeps advancing at ~400/s and CPU stays ~0.5 cores the whole time, including during the 60s stalls; replay_buffer_waits_total climbs during stalls (the replay is waiting on the probe, not kicking it); the probe reports reorder 0 and no error frame while replaying; after it catches up it keeps receiving live frames. Kill the probe if seq goes flat for more than a minute, and roll back. On 35fae9a the same probe with --behind 2000 --stall-every 0 already shows ~190 reorders in 30s.

3. move lightrail back to our relay

zlay/deploy/lightrail-values.yaml: --subscribe https://zlay.waow.tech (currently https://relay1.us-east.bsky.network), then helm upgrade --install lightrail bjw-s/app-template -n zlay --values zlay/deploy/lightrail-values.yaml and commit the change with a changelog line.

Watch for an hour: lightrail RESTARTS must stay 0 (against zlay it exited Completed every ~30 min before the fix; against relay1 it did not). If it exits again, its stderr has the answer: kubectl -n zlay logs deploy/lightrail --previous | grep "a task exited" names the task that ended. zlay side: no ZlayBroadcastStalled, seq flat never, relay_slow_consumers_total not climbing.

4. afterwards

  • changelog entry in the relay repo: image deployed, probe result, lightrail back.
  • the 0.16 backport branch fix/broadcast-backpressure (c904349) can be deleted once 0.17 is proven in prod.
  • lalinsky zio (backend/lalinsky-zio-0.17, b2d2554) is the next backend track; not part of this deploy.