Skip to content

rns: stop the path sweep outlasting the watchdog - #120

Merged
mclueppers merged 1 commit into
mainfrom
fix/path-sweep-watchdog
Sep 5, 2026
Merged

rns: stop the path sweep outlasting the watchdog#120
mclueppers merged 1 commit into
mainfrom
fix/path-sweep-watchdog

Conversation

@mclueppers

Copy link
Copy Markdown
Contributor

The dead-path sweep dereferenced every entry in the path table in one pass, and a dereference reads the record back through microStore — one file opened on LittleFS per entry, each open a directory lookup and several 512-byte flash reads that disable the cache and stall the other core. The cost grew with the table. On a V4 with 200 stored paths the pass took about 32 s against a 30 s watchdog, and the node rebooted every ninety seconds for two days.

The sweep now spends at most kWalkBudgetMs per pass and resumes from a cursor, so every entry is still reached and no pass is long; the walk feeds the watchdog as it goes, which is what makes a slow filesystem survivable rather than fatal. Stepping the iterator is metadata-only, so positions a pass has no use for are skipped without touching flash.

tables: gains snap , the worst walk since boot — the figure that says whether a node is near the same edge.

The dead-path sweep dereferenced every entry in the path table in one
pass, and a dereference reads the record back through microStore — one
file opened on LittleFS per entry, each open a directory lookup and
several 512-byte flash reads that disable the cache and stall the other
core. The cost grew with the table. On a V4 with 200 stored paths the
pass took about 32 s against a 30 s watchdog, and the node rebooted
every ninety seconds for two days.

The sweep now spends at most kWalkBudgetMs per pass and resumes from a
cursor, so every entry is still reached and no pass is long; the walk
feeds the watchdog as it goes, which is what makes a slow filesystem
survivable rather than fatal. Stepping the iterator is metadata-only,
so positions a pass has no use for are skipped without touching flash.

tables: gains snap <ms>, the worst walk since boot — the figure that
says whether a node is near the same edge.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Only minor documentation/comment wording issues were identified; the functional changes align with the watchdog-timeout mitigation described in the PR.

Pull request overview

This PR prevents the dead-path sweep over the microStore-backed path table from running long enough to trip the watchdog by time-slicing the sweep across snapshot passes and feeding the watchdog during the walk. It also surfaces the worst snapshot walk duration since boot so operators can see whether a node is approaching filesystem/path-table limits.

Changes:

  • Adds a per-pass time budget and cursor-based resumption for the dead-path sweep to avoid unbounded filesystem reads in one pass.
  • Feeds the watchdog periodically during path-table record reads to keep long walks survivable.
  • Introduces and logs a new Tables::snapWalkMaxMs metric (worst snapshot walk time since boot).
File summaries
File Description
src/rns/RnsTransport.h Adds Tables::snapWalkMaxMs to report worst snapshot-walk duration since boot.
src/rns/RnsTransport.cpp Implements budgeted, cursor-resumed sweeping and watchdog feeding during path-table reads; publishes the new metric.
src/main.cpp Extends periodic tables log line to include snapWalkMaxMs.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/rns/RnsTransport.cpp
Comment on lines +1715 to +1718
// Records read between watchdog feeds. The budget above ends the walk, but it
// is only checked between records, and one record on a sick filesystem can
// take a long time on its own — so the walk keeps reporting while it runs
// rather than relying on finishing.
Comment thread src/rns/RnsTransport.h
Comment on lines +99 to +100
// pass long. A number here in the seconds means the RNS task is spending
// that long not forwarding.
@mclueppers
mclueppers merged commit dea9b15 into main Sep 5, 2026
18 checks passed
@mclueppers
mclueppers deleted the fix/path-sweep-watchdog branch September 5, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants