Skip to content

node: download receipt log grows unbounded — no rotation, retention, or size cap #802

Closed

Description

@thiras

Follow-up to #248 / PR #790.

Problem

download_receipts.jsonl is an append-only log with one line written per accepted voucher interval (~one per MiB delivered, per the module docs). There is no rotation, truncation, retention window, or size cap anywhere in the module or its runtime wiring. On a long-running, high-throughput node the file grows monotonically for the entire process lifetime and across restarts (opened O_APPEND), eventually exhausting data_dir disk.

Evidence

  • crates/node/src/receipt_log.rs:231 (JsonlReceiptLog::open) — create(true).append(true), no size/age handling.
  • crates/node/src/receipt_log.rs:272 (append) — plain write_all + flush, no bound.
  • Runtime wiring in crates/node/src/runtime/mod.rs opens it once with no retention policy.
  • By contrast every other new stateful component in the same batch of work got explicit bounding (VoucherActivity eviction in feat(cli): add decdn node channels payment-channel snapshot (#749) #791, the session-ticket peer cap, the withdrawn_cache). The receipt log is the lone unbounded-growth sink with no follow-up referenced.

Suggested fix

Add size/age-based rotation (or a documented operator-driven truncation/retention policy) for the receipt log. Note this interacts with #803 — a full disk also back-pressures paid delivery today.

Filed during a repository review; verified not already tracked.

Activity

  1. added
    prio:high
    rust
    on Jun 3, 2026
  2. github-actions commented on Jun 3, 2026

    @github-actions

    🎯 Triage report

    JsonlReceiptLog opens download_receipts.jsonl with O_APPEND and no rotation, truncation, or retention policy. On a sustained high-throughput node this file grows monotonically across restarts until data_dir runs out of disk. The reporter has pinpointed two specific code sites (receipt_log.rs:231 and receipt_log.rs:272) and notes the log is the only unbounded-growth sink added in this batch of work — every other stateful component received explicit eviction bounding. The closely related issue #803 surfaces the compounding risk: a full disk converts the "audit-only" write into an active delivery-stall via the awaited mutex flush on the voucher-accept hot path.

    📊 Assessment

    Dimension Value Reasoning
    Type Bug Missing resource bound causes unbounded disk consumption — operational defect, not a feature gap
    Labels technical, high, rust, prod-blocking (all already applied) Labels are accurate; prod-blocking is correct given real disk-exhaustion risk on production nodes
    Coding agent Suitable Requirements are concrete: add size- or age-based rotation (or a configurable retention window) to JsonlReceiptLog. Both the write path (receipt_log.rs:231, receipt_log.rs:272) and the runtime wiring (runtime/mod.rs) are identified. Success criterion is clear — log must not grow past a bounded limit regardless of uptime or throughput. Needs care around the shutdown/ordering invariants already noted in the in-code comment.

    🔗 Similar issues

    💡 Notes and suggestions

    Recommended implementation approach:

    1. Size-based rotation (simplest, lowest risk): in JsonlReceiptLog::append, check file.metadata()?.len() after each flush and roll to a new timestamped file when it exceeds a configurable max_bytes (e.g., 512 MiB default). Keep N-1 rotated files (configurable keep_files).

    2. Age-based rotation (alternative or combined): rotate once daily; keep last N days.

    3. Config surface: expose [receipt_log] section in the operator config (in common/config schema) with max_bytes and keep_files — this avoids hard-coding operational policy and aligns with how VoucherActivity eviction is tuned.

    Interaction with #803: Rotation alone does not decouple the write from the ack path. Address the two issues independently — #803 requires a channel/fire-and-forget decoupling regardless of whether rotation is in place.

    Shutdown/ordering caveat: The existing in-code comment in client.rs:839 justifies awaiting for ordering guarantees on shutdown. Any rotation implementation must ensure the file handle swap is atomic from the perspective of that invariant (i.e., do not drop unwritten buffered data mid-rotation).

    Sub-tasks checklist:

    • Add max_bytes / keep_files config fields to the ReceiptLogConfig (or create one if absent) in common
    • Implement size-based rotation in JsonlReceiptLog::open / append
    • Wire config into runtime/mod.rs open call
    • Unit-test: write past the cap, assert the old file is closed and a new one created, assert combined file count ≤ keep_files + 1
    • Update operator docs / config schema comments

    Generated by Agentic Triage for issue #802 · sonnet46 460.7K · ◷

    Add this agentic workflows to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/issue-triage.md@94ec5db57374c5b04a4b8eef8b4413f9af44d63f
    
  3. self-assigned this
    on Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

prio:highrust

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions