Re-sort the TimersManager's heap after a timer reset (forward-port #2890, with a test) #3425
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.39) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 267 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.334
Real PR Conversation Timeline
1 comments
"Review active on #3425"
general
weight: 0.35
jmachowinski
Fixes #2889 on
rolling.@jmachowinski's #2890 makes the TimersManager re-sort its heap whenever its timers were updated. Without that, a timer that is reset while it sits below the head of the heap keeps its old place and can wait there forever, below later or cancelled timers. #2890 was merged into
jazzyonly (28.1.11), sorollingandlyrical(32.0.3) still have the bug. Theirrun_timers()re-sorts only when the head timer is cancelled, or after waiting with every timer cancelled.This PR:
git cherry-pick -x 83e0ec56, his authorship and sign-off kept).TestTimersManager.reset_timers_below_cancelled_timers_run.- It adds four cancelled timers and four timers to reset, in turns, below a 1 ms timer at the head of the heap.
- Then it resets the four from the test thread while the timers thread runs. That avoids resetting a timer from inside a timer callback, which deadlocks the EventsExecutor, as noted in #2890.
- A cancelled timer is never due, so without the re-sort the timers thread never looks below one, and two of the four reset timers never run.
Tested on arm64 in an Ubuntu 26.04 container, against Lyrical's packages.
rollingand thelyricalbranch need a newer rcl than those packages have (rcl_timer_set_on_schedule_change_callback), so the tests ran on the 32.0.3 tag. Both commits apply there unchanged.timers_manager.cppandtest_timers_manager.cppon that tag differ fromrollingonly in one#include.| rclcpp 32.0.3 with these two commits | runs passed |
|---|---|
| new test, without the fix | 0/20: reset timers 1 and 3 never run |
| new test, with the fix | 20/20 |
| all
TestTimersManagertests, with the fix | 5/5 || all
TestEventsExecutortests, with the fix | 3/3 |ament_uncrustifyandament_cpplintpass on the changed files.The EventsExecutor is deprecated on
rolling, but Lyrical ships it, and its timers stop firing like this. So once this is in, I'd like to ask for a backport tolyrical.🤖 Generated with Claude Code