Skip to content

fault_manager: run and drop captures by retention priority - #863

Draft
bburda wants to merge 1 commit into
feat/rosbag-retention-5bfrom
feat/rosbag-retention-5c
Draft

bburda wants to merge 1 commit into
feat/rosbag-retention-5bfrom
feat/rosbag-retention-5c

Conversation

@bburda

@bburda bburda commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Pull Request

Summary

Today the capture queue runs captures in arrival order. When it is full it drops by snapshots.capture_queue_full_policy alone, so the most important capture can be the one dropped. Issue 705 rule 6 asks for priority order: "When the capture queue is full, the capture with the lowest priority is dropped. Pending captures run in priority order." This PR does that with the retention priority of each capture's fault.

This PR is on top of eleven PRs in the stack. Please review those first. The diff of this PR is against the branch of the PR directly below it.

What it adds:

  • Priority of a capture. It is its fault's retention priority, resolved from the fault's current severity. It is read when a worker picks a capture and when a full queue chooses what to drop, so a fault re-reported at a severity with a higher priority moves up while it waits.
  • Pick. A free worker runs the waiting capture with the highest priority, and arrival order among equal priorities.
  • Full queue. The capture with the lowest priority is dropped, the incoming one included. Among the lowest, capture_queue_full_policy decides: reject_newest drops the incoming one when it ties, drop_oldest drops the oldest.
  • One policy snapshot per decision. The priorities of all compared captures are read in one call. The read takes no lock of the queue or of the retention and logs nothing; a fault that cannot be read counts as priority 0. If the waiting captures keep changing during three reads in a row, that one decision uses arrival order and the policy, with a DEBUG line.
  • Logs. Each dropped capture logs one WARN with its fault code and priority, with no throttle.
  • Docs: docs/config/fault-manager.rst, docs/tutorials/snapshots.rst, the fault manager README and design doc.

What changes for users

  • Without valid retention rules nothing changes: every priority is 0, so captures keep arrival order and today's capture_queue_full_policy.
  • With rules, the order is strict. There is no aging: a low-priority capture can wait as long as higher ones keep arriving.
  • On a full queue, a report waits for the priority reads. With valid rules, the report that hits a full queue reads the waiting captures' priorities from the fault storage before it returns.
  • The drop log is no longer throttled, and it names the fault code and the priority.

Issue


Type

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

Testing

  • colcon build --packages-up-to ros2_medkit_fault_manager --cmake-args -DPOSTGRES_SUPPORT=ON, then colcon test --packages-select ros2_medkit_fault_manager and colcon test-result --verbose.
  • The real-process test is src/ros2_medkit_fault_manager/test/integration/test_capture_queue_priority.test.py, with one capture worker held by a blocker capture. It covers:
    • escalation while waiting;
    • the lowest dropped, also when it is the incoming one;
    • ties under both policies;
    • an escalation that changes the victim;
    • back-to-back drops, each logged;
    • no rules and an invalid configuration, which keep today's behaviour.
  • test_capture_thread_pool.cpp has three in-process cases for what a real process cannot show: the priority reads run outside the queue mutex, one decision reads its priorities in one call, and with two workers no job runs twice or is lost.
  • I ran this on Jazzy. 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 December 1, 2026 13:21
@bburda
bburda force-pushed the feat/rosbag-retention-5c branch 2 times, most recently from c4a4c9f to ec06e48 Compare December 2, 2026 12:15
* feat(fault_manager): run and drop captures by retention priority
* fix(fault_manager): one policy snapshot per capture queue decision
* docs(fault_manager): the capture queue's FIFO fallback and the lock-free policy methods
@bburda
bburda force-pushed the feat/rosbag-retention-5c branch from ec06e48 to c70b262 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.

1 participant