Skip to content

Dashboard and ledger rollups still hold the live writer during long SQL work #1280

Closed

Description

@frahlg

On v3.5.3-beta.1 (8650c58), dashboard pruning and energy-ledger rollup still acquire historyWriteMu before aggregation and deletion. They pass the caller's long maintenance context into the transaction. Their mutex wait also ignores cancellation. The newer short archive transaction budget does not cover these paths.

A 24-hour dashboard time range bounds time, not bytes or SQL work. Reading/aggregating a dense day can therefore exclude live telemetry for its entire scan. Ledger rollup has the same shape. A stalled mutex owner can also keep shutdown waiting after the context expires.

Move dashboard aggregation into a read snapshot outside the live writer mutex, then commit a short atomic aggregate-and-delete transaction. On snapshot conflicts recompute from fresh input so late rows are not lost. Reduce the time range when a write exceeds its budget. Roll ledger rows in bounded batches with additive sums and source-row deletion in the same transaction. Honor cancellation while waiting for locks and yield between batches.

Test delayed scans, concurrent live commits, cancellation, late corrections, exact averages/energy totals and repeat runs. Related: #1275, #1276, #1279. This is a source-confirmed path missing the archive write budget; hardware testing must establish its contribution to runtime delays. Fix before stable promotion.

Activity

  1. frahlg commented on Sep 24, 2026

    @frahlg
    MemberAuthor

    This is in the code that v0.132.0-beta.1 is running.

    Dashboard aggregation is read outside the live writer mutex, then committed as a short write. A snapshot conflict rereads the input, so a late row is kept. Ledger rollup is batched, additive, and deletes source rows in the same transaction. Both honor cancellation while waiting for the writer lock.

    Passed locally: TestDashboardRollupReadYieldsAndKeepsLateRows, TestHistoryRollupLockWaitHonorsCancellation, TestEnergyLedgerBatchedRollupPreservesExactTotals.

    Closing. Backup IO on the Pi is #1246.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions