Skip to content

fault_manager: add one atomic rosbag write primitive and pin today's retention behaviour - #834

Draft
bburda wants to merge 1 commit into
mainfrom
feat/rosbag-retention-0a
Draft

bburda wants to merge 1 commit into
mainfrom
feat/rosbag-retention-0a

Conversation

@bburda

@bburda bburda commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Pull Request

Summary

Issue 705 adds configurable rosbag retention. The rules will decide which recordings to keep, delete or replace. Today the retention logic is spread over several storage mutators, and each one changes rows in its own transaction. A rule that stores one recording and removes others needs one step that cannot stop half way.

This PR is the first of a stack. It does not change what the fault manager does.

What it adds:

  • FaultStorage::apply_rosbag_changes. It upserts rows, removes links and removes whole recordings in one transaction, and returns each path whose last link the call removed. It applies no per-fault cap and never deletes files. It is implemented for the in-memory, SQLite (BEGIN IMMEDIATE) and PostgreSQL backends. A change set that inserts and removes the same link throws std::invalid_argument before any row changes.
  • Storage parity tests that run the new primitive on all three backends, including atomicity when an insert or a delete fails.
  • Tests that start fault_manager_node as its own process and drive it over its ROS services. They pin the current behaviour: quota eviction order, a burst recording counted once and evicted whole, an oversized recording kept, the per-fault cap together with the quota, failing stores, a clear racing a store, shutdown during a post-fault window, and stale rows. The quota and clear flows also run against a PostgreSQL server.
  • A sanitizer-fault-manager CI job that builds the fault manager chain with ASan and with TSan and runs the package tests, launch tests included. The workspace sanitizer sweeps skip the package, as they do graph_watchdog.

The existing mutators are unchanged and nothing calls the new primitive yet. The next PR (rosbag-retention-0b) builds on this one.

What changes for users

Nothing. No parameter, service, log line or default changes.


Issue


Type

  • Bug fix
  • New feature or tests
  • Breaking change
  • Documentation only

Testing

  • colcon build --packages-up-to ros2_medkit_fault_manager (add --cmake-args -DPOSTGRES_SUPPORT=ON for the PostgreSQL backend), then colcon test --packages-select ros2_medkit_fault_manager and colcon test-result --verbose.
  • The real-process tests are test_rosbag_quota.test.py and test_rosbag_quota_pg.test.py in src/ros2_medkit_fault_manager/test/integration. Run them with ctest -R rosbag. The PostgreSQL one needs a PostgreSQL server.
  • The parity tests are in test_rosbag_storage_parity.cpp.
  • I ran this on Jazzy with PostgreSQL 14. Humble and Lyrical run in CI. clang-tidy on the changed files reports nothing new.

Checklist

  • Breaking changes are clearly described (and announced in docs / changelog if needed)
  • Tests were added or updated if needed
  • Docs were updated if behavior or public API changed

@bburda
bburda added this pull request to stack #836 November 27, 2026 19:25
@bburda
bburda force-pushed the feat/rosbag-retention-0a branch from aee4284 to cd07db5 Compare December 1, 2026 15:43
}
}
for (const auto & path : candidates) {
if (!path_referenced(path)) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

path_referenced() returns false for any step() result other than SQLITE_ROW, so an I/O or corruption error on this COUNT reads as "no link left". If the COMMIT then goes through, a directory that another fault's committed row still names comes back in orphaned_paths and the caller removes it. COUNT(*) always yields a row on success, so path_referenced() could throw on anything else and roll the change set back.

@bburda
bburda force-pushed the feat/rosbag-retention-0a branch from cd07db5 to b116bde Compare December 2, 2026 12:15
…retention behaviour

* test(fault_manager): pin rosbag retention against a real fault manager process
* feat(fault_manager): add apply_rosbag_changes beside the rosbag mutators
* ci: run the fault manager tests under ASan and TSan
* test(fault_manager): wait for the earlier subscriber to leave before the next run
* test(fault_manager): put multi-line docstring summaries on the second line
* test(fault_manager): tighten the upsert, store-failure and race checks
* ci: make the fault manager sanitizer job comments describe this job
* test(fault_manager): rosbag test harness waits for the payload
@bburda
bburda force-pushed the feat/rosbag-retention-0a branch from b116bde to f2a3dde Compare December 2, 2026 18:24

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants