Skip to content

Fixes race condition of watchable.Map between Close and Subscribe#5522

Merged
Xunzhuo merged 2 commits intoenvoyproxy:mainfrom
mathetake:fixesracestandalone
Mar 18, 2025
Merged

Fixes race condition of watchable.Map between Close and Subscribe#5522
Xunzhuo merged 2 commits intoenvoyproxy:mainfrom
mathetake:fixesracestandalone

Conversation

@mathetake
Copy link
Copy Markdown
Member

@mathetake mathetake commented Mar 17, 2025

What type of PR is this?

fix: race condition on using watchable.Map

What this PR does / why we need it:

These watchable.Map's two methods, Subscribe and Close, are not supposed to be called from multiple goroutines since inside these implementations, Subscribe calls WaitGroup.Add vs Close calls WaitGroup.Wait, which is a forbidden use of WaitGroup API. This partially fixes the forbidden use regarding standalone mode, but there's a plenty of places that violates the rule, which will be fixed in a follow up PR.

Which issue(s) this PR fixes:

Partially fixes: #5505

Release Notes: No

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
@mathetake mathetake marked this pull request as ready for review March 17, 2025 17:07
@mathetake mathetake requested a review from a team as a code owner March 17, 2025 17:07
@mathetake
Copy link
Copy Markdown
Member Author

cc @arkodg

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 17, 2025

Codecov Report

Attention: Patch coverage is 44.44444% with 10 lines in your changes missing coverage. Please review.

Project coverage is 65.25%. Comparing base (d2da770) to head (3212bd6).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
internal/xds/server/runner/runner.go 0.00% 6 Missing ⚠️
internal/infrastructure/runner/runner.go 0.00% 4 Missing ⚠️

❌ Your patch status has failed because the patch coverage (44.44%) is below the target coverage (60.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5522      +/-   ##
==========================================
+ Coverage   65.17%   65.25%   +0.07%     
==========================================
  Files         213      213              
  Lines       34029    34034       +5     
==========================================
+ Hits        22179    22209      +30     
+ Misses      10520    10501      -19     
+ Partials     1330     1324       -6     

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Copy Markdown
Contributor

@arkodg arkodg left a comment

Choose a reason for hiding this comment

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

LGTM thanks !

@arkodg arkodg requested review from a team March 17, 2025 18:03
@arkodg arkodg added this to the v1.4.0-rc.1 milestone Mar 17, 2025
Copy link
Copy Markdown
Member

@Xunzhuo Xunzhuo left a comment

Choose a reason for hiding this comment

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

Nice catch, thanks!

@Xunzhuo Xunzhuo merged commit 042fc1e into envoyproxy:main Mar 18, 2025
9 checks passed
@mathetake mathetake deleted the fixesracestandalone branch March 18, 2025 16:20
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.

race condition between watcheabler.Map.Close and Subscribe

3 participants