← Back to Pull requests

Re-sort the TimersManager's heap after a timer reset (forward-port #2890, with a test) #3425

Open
unknown opened this pull request with 267 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 20, 2026 18:29 UTC
Author

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 jazzy only (28.1.11), so rolling and lyrical (32.0.3) still have the bug. Their run_timers() re-sorts only when the head timer is cancelled, or after waiting with every timer cancelled.

This PR:

  • Cherry-picks his commit unchanged (git cherry-pick -x 83e0ec56, his authorship and sign-off kept).

  • Adds the unit test asked for in #2890, 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.

  • rolling and the lyrical branch 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.cpp and test_timers_manager.cpp on that tag differ from rolling only 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 TestTimersManager tests, with the fix | 5/5 |
    | all TestEventsExecutor tests, with the fix | 3/3 |

    ament_uncrustify and ament_cpplint pass 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 to lyrical.

    🤖 Generated with Claude Code

    Diff: 267 lines (+200 / -67) across 3 files Reviewer: jmachowinski Review duration: 14217m
    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
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.4% (MEDIUM) · Higher = larger blast radius
    39.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 21.0% · Safe to merge
    21.0%
    Repository