Skip to content

[Bug] Fix race condition in interface model cancel thread#3508

Merged
ryan-pratt merged 5 commits into
mainfrom
bug/inferface-model-race-condition
Jun 29, 2026
Merged

[Bug] Fix race condition in interface model cancel thread#3508
ryan-pratt merged 5 commits into
mainfrom
bug/inferface-model-race-condition

Conversation

@ryan-pratt

Copy link
Copy Markdown
Contributor

When uninstalling a plugin, there was a race condition where InterfaceStatusModel.set() or RouterStatusModel.set() could be called during the last loop iteration, immediately after a different thread removed them. This resulted in orphaned data in valkey.

There was also an issue in interface_model.rb where we never called .destroy() on the model if we encountered an exception earlier in the block.

@ryan-pratt ryan-pratt requested review from jmthomas and ryanmelt June 26, 2026 18:22
Logger.error("Error undeploying interface/router model #{@name} in scope #{@scope} due to #{error}")
ensure
begin
if type == 'INTERFACE'
Comment thread openc3/lib/openc3/models/interface_model.rb Fixed
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.28%. Comparing base (70c37ff) to head (33d25ff).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...lib/openc3/microservices/interface_microservice.rb 90.00% 1 Missing ⚠️
openc3/lib/openc3/models/interface_model.rb 80.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3508   +/-   ##
=======================================
  Coverage   79.28%   79.28%           
=======================================
  Files         689      689           
  Lines       57332    57338    +6     
  Branches      728      728           
=======================================
+ Hits        45455    45462    +7     
+ Misses      11799    11798    -1     
  Partials       78       78           
Flag Coverage Δ
python 80.38% <ø> (-0.02%) ⬇️
ruby-api 81.06% <ø> (+0.11%) ⬆️
ruby-backend 83.13% <86.66%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

all_interfaces = InterfaceStatusModel.all(scope="DEFAULT")
self.assertEqual(all_interfaces["INST_INT"]["state"], "ATTEMPTING")

for _stdout in capture_io():
@ryan-pratt ryan-pratt force-pushed the bug/inferface-model-race-condition branch from eb4b86a to 3f11a94 Compare June 26, 2026 19:40

@EmilyRagan EmilyRagan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@ryan-pratt ryan-pratt merged commit 5208fa2 into main Jun 29, 2026
36 of 37 checks passed
@ryan-pratt ryan-pratt deleted the bug/inferface-model-race-condition branch June 29, 2026 21:26
@sonarqubecloud

Copy link
Copy Markdown

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.

3 participants