Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a data race in watcher.go #2952

Merged
merged 3 commits into from
Apr 15, 2024
Merged

Fix a data race in watcher.go #2952

merged 3 commits into from
Apr 15, 2024

Conversation

blampe
Copy link
Contributor

@blampe blampe commented Apr 15, 2024

Ran into a small data race while testing await logic.

This PR fixes the underlying race condition as well as a race-y test.

Comment on lines +117 to +118
o, err := ow.pollFunc()
results <- result{Obj: o, Err: err}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The race was due to this write to obj happening across goroutines. We can instead communicate that state via the results channel.

Copy link

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

Copy link

codecov bot commented Apr 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 29.18%. Comparing base (cd36ac9) to head (985c2ce).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2952      +/-   ##
==========================================
+ Coverage   29.16%   29.18%   +0.01%     
==========================================
  Files          61       61              
  Lines        8194     8196       +2     
==========================================
+ Hits         2390     2392       +2     
  Misses       5600     5600              
  Partials      204      204              

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

@@ -20,6 +20,7 @@ import (
"testing"
"time"

"go.uber.org/atomic"
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we use sync/atomic instead?

@blampe blampe added the impact/no-changelog-required This issue doesn't require a CHANGELOG update label Apr 15, 2024
@blampe blampe merged commit cb9002f into master Apr 15, 2024
18 checks passed
@blampe blampe deleted the blampe/watcher-race branch April 15, 2024 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impact/no-changelog-required This issue doesn't require a CHANGELOG update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants