WPILOGWriter: stop logging gracefully when disk is full to prevent robot loop overruns#260
Conversation
When log storage fills up, synchronous flush() calls in putTable() can block the main robot loop, causing erratic mechanism behavior mid-match. - At startup: fire kError Alert and abort if < 50 MB free; fire kWarning Alert if < 1 GB free but continue logging - Every ~10 seconds during operation: recheck free space with the same thresholds; on < 50 MB, close the log and set isOpen=false so the existing guard short-circuits all future calls without blocking on I/O - Guard end() against calling log.close() if already closed by the disk-full path Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add :::warning admonition to existing-projects.md and vscode-welcome.md explaining the 1 GB warning and 50 MB shutdown thresholds - Apply Spotless formatting to WPILOGWriter.java Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… recovers - Reset both alerts at the top of start() so stale warnings from a previous run don't persist after a reboot with a cleared drive - In the periodic check, explicitly clear lowSpaceAlert in the else branch so the alert dismisses if space somehow rises back above 1 GB Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Shouldn't this be handled at the |
|
If you mean Let me know if I’m misunderstanding your comment. |
|
Sorry, I misunderstood. I thought AdvantageKit utilizes WPILib's logging capabilities. Is that not the case? I guess maybe not, as AdvantageKit was created before WPILib had logging. |
|
AdvantageKit does utilize WPILib's logging. WPILogWriter is the class in AdvantageKit that handles writing periodic tables to WPILOG files If you are curious, consider reading the source code of that class or some other parts of AdvantageKit for a better understanding of how things are structured. That way you'll be more informed with your contributions and suggestions. |
|
Thanks, what I meant to say in general is that -- can this feature be added to WPILib's side, perhaps in |
|
For WPILib we use |
Summary
Fixes #259
When log storage fills up, synchronous
flush()calls inputTable()can block the main robot loop, causing erratic mechanism behavior mid-match (e.g. mechanisms barely responding, commands not executing). This was observed in competition when a USB drive filled up and write errors caused the logger's queue to back up and stall the 20ms robot loop.kErrorAlert and abort logging entirelykWarningAlert but continue loggingputTable()), recheck free space with the same thresholds; on < 50 MB, close the log and setisOpen = falseso the existing guard short-circuits all future calls without blocking on I/OlowSpaceAlertin the periodic check if space rises back above 1 GBend()against callinglog.close()if the log was already closed by the disk-full path:::warningadmonition toexisting-projects.mdandvscode-welcome.mddocumenting the thresholds and advising teams to clear logs regularlyTest plan
./gradlew :akit:compileJava)./gradlew spotlessCheck)publishToMavenLocaland consumed in a robot project running in simulationend()when logging was stopped early by the disk-full path🤖 Generated with Claude Code