← Back to Pull requests

Show a redelivered container exit once in Logs history, with the OOM kill any copy saw #3152

Closed
unknown closed this pull request without merging on Oct 23, 2026 01:00 UTC
View on GitHub
unknown unknown commented on Oct 23, 2026 00:49 UTC
Author

Fixes #3129.

Summary

Logs showed Couldn't load older logs when one history page held the same container exit twice. The dashboard's collection.insert threw on the repeated row id, and the page loaded nothing.

sequenceDiagram
    participant D as Docker
    participant H as ployz observe (harvest.rs)
    participant F as exits.jsonl
    participant Q as ployzd query.rs read_exits
    participant C as Cloud Logs page
    D->>H: die (exit 137)
    H->>F: append exit (ts T)
    Note over H: ployz observe restarts, resumes from the die
    D->>H: die again (same ts T)
    H->>F: append exit (ts T) again: retry-safe, may carry better OOM evidence
    C->>Q: history page
    Q-->>C: one row for ts T (copies merged, OOM if any copy says so)

  • Daemon read side (query.rs). read_exits collapses the lines that share one exit's ts into one row, and that row is OOM if any copy says so. Row ids and the format don't change.

  • Daemon write side (harvest.rs). This is unchanged from main on purpose. Each settlement still appends, so a failed append is retried on the next replay. A replay can also carry better evidence: the first settle can miss an OOM kill that a later inspect confirms. The first commit moved the append behind "already settled". R1 showed that lost both properties, so it's reverted, and the end-to-end test stays.

  • Dashboard (container-log.collection.ts). It removes in-page repeats, for exits.jsonl files that 0.3.1 daemons already wrote, and keeps the "Out of memory" copy.
  • Evidence

    Tests. Each failed before its fix.

  • an_exit_kept_again_shows_once_with_the_oom_kill_any_copy_saw: before, [(10,false),(10,true),(20,…)…]. After, one row per ts, OOM OR-ed.

  • history_shows_an_exit_settled_again_once_with_the_oom_kill_it_learned: settles Unanswered, restarts, replays with an OOM inspect, then reads one page through query::page. Before, 2 rows. After, 1 row with OOM.

  • Dashboard container-log.collection.test.ts: on main, CollectionOperationError: Cannot insert document with ID "server/a/exit/5" because it already exists. After the fix, [exited, killed] keeps "Out of memory (exit code 137)".

  • cargo test -p ployzd --lib observe: 296 passed. Clippy, fmt, pnpm typecheck and lint are clean.
  • Real Server (SERVERS=1).

  • Before, on the 0.3.1 daemon: web was set to Restart: Never and killed, and ployz-observe was restarted. exits.jsonl held the exit twice, the /api/runtime/logs page repeated its id, and Logs showed "Couldn't load older logs."

  • After, on this branch's daemon, with the same steps: exits.jsonl still holds the line twice, by design. The real POST /api/runtime/logs returned 85 rows with no repeated id, and web's "Exited with code 137" appears once. Logs load, and searching "Exited" shows it once.

  • Could not run: an OOM on a real Server. Docker 29.7.0 on this lab reported OOMKilled=false for a real memory-cgroup kill, so the OOM merge is covered only by the unit tests above.
  • Review.

  • R1, Codex + Opus: Codex found two BUGs in the first approach (history lost on a failed write, and better OOM evidence dropped). Both are fixed by moving the dedupe to the read side.

  • R2, Codex on the full diff: no BUG. Two NITs left as they are:

  • - A page cursor issued before the upgrade can repeat its boundary exit once. The dashboard ignores the repeated id.
    - Against an old daemon, copies split across pages keep the first one seen.

    Bets

  • Bet 8, Evidence over claims. History keeps every observation and merges them on read, so a later, better observation of an exit (an OOM kill) isn't thrown away.

  • Bet 10, Client-first, daemon when forced. The dashboard alone can't fix this. Only the daemon sees both copies when they land on different pages, so the merge lives in ployzd, and the dashboard keeps a fallback for old daemons.

  • Stable promise. No format change: the same exits.jsonl lines, the same history row shape, the same ids.
  • Merge Danger

    Door: two-way.

    Blast Radius: Logs history. Exits read from exits.jsonl and the Logs page merge. A page cursor from before the upgrade can repeat one exit once.

    Diff: 525 lines (+393 / -132) across 6 files Reviewer: nick-potts Review duration: 11m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.48) × (1 − Review Confidence (0.53)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 525 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 85% · Reviewer familiarity: 35%
    53%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.375
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3152"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 53.1% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.8% (MEDIUM) · Higher = larger blast radius
    47.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 53.1% · Lower = rushed or shallow review
    53.1%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.4% · Safe to merge
    22.4%
    Repository