Skip to content

Backup IO delays durable charging-goal saves on Raspberry Pi #1246

Closed

Description

@frahlg

Full backup can delay a durable charging-goal save on the same Raspberry Pi SD card. This remains a release gate for the SQLite + Parquet candidate; no new storage code has been installed on the live controller.

Reproduction uses synthetic data only: 3,000 dashboard rows with about 48 MiB of JSON, a concurrent durable setting save every 50 ms, and telemetry commits. Run FTW_STORAGE_ADMISSION=1 go test -v ./internal/state -run TestStorageAdmission -count=1 in the storage candidate branch based on #1240.

Measured on 2026-09-13:

  • Without backup, normal durable saves in the low-priority test peaked at 330 ms; all 200 telemetry writes committed.
  • With backup and normal IO priority, goal-save latency reached 3.94 s, exceeding the test's 2 s limit. Peak process RSS was 34 MiB.
  • Giving the entire test idle IO priority also deprioritizes goal writes and makes the delay worse: 16.8 s before additional syncing, and up to 45.2 s in a later run. These runs must not be presented as normal production latency.
  • strace confirms simultaneous waits in state and history WAL fsync calls. Splitting the databases alone and pausing between 1 MiB copy batches did not meet the latency gate. The tested Pi has no enabled memory cgroup controller; requested container memory limits were not enforced.

Work in progress: reduce and sync copy batches, bound dirty compressed/archive output, and repeat backup/restore with concurrent goal writes on the target. Preserve FULL sync for goals and committed history. Do not increase the latency threshold to make the test pass.

Acceptance: verified full backup and separate restore; unchanged goal/session/identity; all admitted telemetry committed; no timeout/rejection; durable goal writes below the existing 2 s limit at normal production priority. Retain the low-priority stress results as a separate limit, and report measured RSS separately from any enforced memory limit.

Related: #1234 covers the earlier DuckDB full-backup memory failure.

Activity

  1. added
    release-blocker
    on Sep 14, 2026
  2. reopened this on Sep 14, 2026
  3. frahlg commented on Sep 17, 2026

    @frahlg
    MemberAuthor

    Further target evidence from the opt-in synthetic fixtures, while an existing Core process remained active on the same Pi filesystem:

    • Default backup path: maximum durable goal save 6.43 seconds, failing the unchanged 2-second limit.
    • Experimental PERSIST journal / 64 KiB copy batches: 12.63 seconds; not retained.
    • Experimental MEMORY journal / 256 KiB batches: 4.01 seconds; not retained.
    • Control: FTW_STORAGE_ADMISSION=1 go test ./internal/state -run '^TestStorageAdmissionDurableGoalsWithoutBackup$' -count=10 -v also fails one run at 8.28 seconds. Across all ten runs, all 2,000 synthetic telemetry ticks committed and none were rejected.

    The longer control disproves attributing every stall to the backup. A traced run shows long filesystem sync calls affecting separate database WAL files; tracing adds substantial overhead, so its latency is not an admission result. We still need to isolate concurrent Core maintenance and target filesystem behavior. Keep #1246 open and retain the 2-second criterion. Do not weaken goal/telemetry durability to make the fixture pass. #1247 remains relevant to avoiding synchronous disk work in control paths.

  4. frahlg commented on Sep 17, 2026

    @frahlg
    MemberAuthor

    Final candidate evidence, 2026-09-17, normal process IO priority on the same Pi while production Core remained active:

    • Test binary built from 8a3ae68d69143f9d63256f0d71ec46f1306880c3, now merged by fix(control): keep EV and model disk writes outside safety ticks #1300 as 0b2baef313d632432d1dd04d786884056054fe18.
    • FTW_STORAGE_ADMISSION=1 GOMEMLIMIT=192MiB ./control-state-reviewed.test -test.run TestStorageAdmission -test.count=1 -test.timeout=8m -test.v.
    • Without backup: maximum durable goal write 443.37 ms; all 200 telemetry ticks committed, none rejected; peak RSS 21.32 MiB. Passed.
    • With the 48 MiB backup fixture: maximum durable goal write 2.227903413 s. Failed the unchanged 2 s limit. Telemetry consistency checks passed before that assertion. Peak RSS 35.62 MiB. This run stopped at the latency assertion before reaching its restore checks; it is not a backup/restore pass.
    • These are separate temporary databases on the production filesystem. They do not measure a full maintenance cycle of the installed history. GOMEMLIMIT is a Go runtime target, not an enforced host memory limit.

    #1300 removes the identified session, vehicle-anchor, model and identity disk operations from safety ticks. Its blocked-write tests pass on the Pi, including a new safety fault after an earlier normal tick queues a write. That closes #1247; it does not satisfy this disk-latency gate. Keep #1246 open. Do not relax FULL sync or increase the two-second limit.

    Next evidence needed: the final candidate under controlled Core maintenance load, with the active writer and archive work identified, followed by the same full backup/restore admission test. Production remains on v3.5.3-beta.1; no deployment occurred in this work.

  5. reopened this on Sep 17, 2026
  6. frahlg commented on Sep 24, 2026

    @frahlg
    MemberAuthor

    Measured again on homelab-rpi on 2026-09-24, synthetic fixture only (FTW_STORAGE_ADMISSION=1, 3,000 dashboard rows, about 48 MiB). The household database was not used. The card's scheduler is mq-deadline, which ignores IO priority.

    Scratch location Max durable goal save RSS
    No backup 442 ms 21 MiB
    On the SD card, 256 KiB commits 2.65 s 35 MiB
    On the SD card, 64 KiB commits 2.11 s 35 MiB
    On the SD card, 16 KiB commits 2.65 s 36 MiB
    tmpfs (/dev/shm) 18 ms 59 MiB

    The 2 s limit was not raised. Smaller on-disk batches did not meet it. #1369 writes the raw export to tmpfs when the file fits, and the same fixture then saved the goal in 18 ms with the archive still verifying. The running v0.132.0-beta.1 service does not include that change yet.

  7. frahlg commented on Sep 24, 2026

    @frahlg
    MemberAuthor

    Shipped in v0.132.1-beta.1 (800702a). The raw backup export uses tmpfs when the file fits. On homelab-rpi the 48 MiB fixture then saved a durable goal in 18 ms, under the 2 s limit, and the archive still verified. The running service does not have this binary until it is updated to that beta.

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

    release-blocker

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions