← Back to Pull requests

Wake every wait set a condition is attached to #271

Merged
Yadunund merged 4 files (118 lines) on Dec 02, 2026 16:54 UTC
View on GitHub
Yadunund Yadunund commented on Nov 24, 2026 18:38 UTC
Author

Description

Addresses same bug as ros2/rmw_zenoh#1109, which was fixed there in ros2/rmw_zenoh#1110. Caught by ros2/rmw_implementation#319, which fails on Connext until this merges.

### Is this user-facing behavior change?

No API change. A node whose entities are briefly in two wait sets no longer stops waking up.

### Did you use Generative AI?

Yes, Claude Opus 5.5 helped write the change. I reviewed and tested it.

### Additional Information

Ubuntu 26.04, rolling, RTI Connext 7.7.0:

- TestWaitSetSharedEntity from ros2/rmw_implementation#319: both cases pass 3/3 with this change. On unmodified rolling both fail 3/3, because the blocked wait set only wakes at its 10 s timeout.
- The rest of test_rmw_implementation (17 binaries) passes with and without the change.
- colcon test of rmw_connextdds_common and rmw_connextdds passes.
- Not covered: rmw_connextddsmicro was not built.

Diff: 118 lines (+68 / -50) across 4 files Reviewer: fgallegosalido Review duration: 11416m
All Vouch review confidence checks passed
Residual risk 0.12 = Change Risk (0.41) × (1 − Review Confidence (0.71)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.41 · 118 lines diff across 4 files
0.41
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.44 · 5 substantive comment(s)
0.44
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
71%
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
Diff Size diff_size
0.286
Ai Authored ai_authored
0.050
Real PR Conversation Timeline
10 items
fgallegosalido fgallegosalido commented on code on Nov 27, 2026 11:43 UTC
Code Review
rmw_connextdds/include/rmw_connextdds/rmw_waitset_std.hpp:1
@@ -129,18 +124,27 @@ class RMW_Connext_Condition
 
     action();
 
-    if (nullptr != this->waitset_mutex) {
-      std::lock_guard<std::mutex> lock(*this->waitset_mutex);
-      update_condition();
-    } else {
-      update_condition();
-    }
+    lock_waitsets_and_update(this->waitsets.begin(), update_condition);
   }
 
 protected:
   std::mutex mutex_internal;
-  std::mutex * waitset_mutex;
-  std::condition_variable * waitset_condition;
+  // Ordered by mutex address, so every update locks shared wait sets in the same order.
+  std::map<std::mutex *, std::condition_variable *> waitsets;
+
+  template<typename FunctorT>
+  void
+  lock_waitsets_and_update(

I prefer a non-recursive version. What about this? It is not recursive and avoids having to pass the iterator, simplifying the code a lot:

  template<typename FunctorT>
  void
  lock_waitsets_and_update(FunctorT && update_condition)
  {
    std::vector<std::unique_lock<std::mutex>> locks;
    locks.reserve(this->waitsets.size());

    for (const auto & waitset : this->waitsets) {
      locks.emplace_back(*waitset.first);
    }

    update_condition();
  }

fgallegosalido fgallegosalido requested changes on Nov 27, 2026 11:52 UTC
Changes Requested Reviewer

Requested changes.

mjcarroll mjcarroll commented on Nov 27, 2026 16:15 UTC
Contributor

Getting this merged should get CI back to green.

Yadunund Yadunund commented on code on Dec 01, 2026 17:14 UTC
Code Review
rmw_connextdds/include/rmw_connextdds/rmw_waitset_std.hpp:1
@@ -129,18 +124,27 @@ class RMW_Connext_Condition
 
     action();
 
-    if (nullptr != this->waitset_mutex) {
-      std::lock_guard<std::mutex> lock(*this->waitset_mutex);
-      update_condition();
-    } else {
-      update_condition();
-    }
+    lock_waitsets_and_update(this->waitsets.begin(), update_condition);
   }
 
 protected:
   std::mutex mutex_internal;
-  std::mutex * waitset_mutex;
-  std::condition_variable * waitset_condition;
+  // Ordered by mutex address, so every update locks shared wait sets in the same order.
+  std::map<std::mutex *, std::condition_variable *> waitsets;
+
+  template<typename FunctorT>
+  void
+  lock_waitsets_and_update(
Yadunund Yadunund commented on Dec 01, 2026 17:20 UTC
Author

Getting this merged should get CI back to green.

@mjcarrol my bad for merging the rmw_implementation tests before getting these changes in first. Will push this through.

fgallegosalido fgallegosalido approved these changes on Dec 01, 2026 17:20 UTC
Approved Reviewer

Approved these changes.

fgallegosalido fgallegosalido commented on Dec 02, 2026 09:03 UTC
Contributor

@Yadunund only the Linux build failed hard for unrelated reasons. Windows looks fine, as failing tests do not seem related to the changes here.

Assignees
Yadunund Yadunund
Labels
risk: low confidence: 71.1% 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: 41.0% (MEDIUM) · Higher = larger blast radius
41.0%
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: 71.1% · Lower = rushed or shallow review
71.1%
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: 11.8% · Safe to merge
11.8%