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

watch: data race / segfault fixes #10393

Merged
merged 2 commits into from
Mar 23, 2023
Merged

watch: data race / segfault fixes #10393

merged 2 commits into from
Mar 23, 2023

Conversation

milas
Copy link
Contributor

@milas milas commented Mar 22, 2023

What I did
Was getting segfaults with multiple services using x-develop and watch at the same time. Turns out the Moby path matcher lazily initializes the regex pattern internally the first time it's used, so it's not goroutine-safe.

Change here is to not use a global instance for the ephemeral path matcher, but a per-watcher instance.

Additionally, the data race detector caught a couple other issues that were easy enough to fix:

  • Use the lock that's used elsewhere for convergence before manipulating
  • Eliminate concurrent map access when triggering rebuilds

(not mandatory) A picture of a cute animal, if possible in relation to what you did
bear prying open a trash can

Was getting segfaults with multiple services using
`x-develop` and `watch` at the same time. Turns out
the Moby path matcher lazily initializes the regex
pattern internally the first time it's used, so it's
not goroutine-safe.

Change here is to not use a global instance for the
ephemeral path matcher, but a per-watcher instance.

Additionally, the data race detector caught a couple
other issues that were easy enough to fix:
 * Use the lock that's used elsewhere for convergence
   before manipulating
 * Eliminate concurrent map access when triggering
   rebuilds

Signed-off-by: Milas Bowman <[email protected]>
@milas milas added the kind/bug label Mar 22, 2023
@milas milas requested a review from a team March 22, 2023 22:14
@milas milas self-assigned this Mar 22, 2023
@milas milas requested review from nicksieger, ndeloof, StefanScherer, ulyssessouza, glours and laurazard and removed request for a team March 22, 2023 22:14
@codecov
Copy link

codecov bot commented Mar 22, 2023

Codecov Report

Patch coverage: 91.66% and project coverage change: +0.02 🎉

Comparison is base (6bedc19) 60.06% compared to head (16d5354) 60.09%.

Additional details and impacted files
@@            Coverage Diff             @@
##               v2   #10393      +/-   ##
==========================================
+ Coverage   60.06%   60.09%   +0.02%     
==========================================
  Files         104      104              
  Lines        9008     9012       +4     
==========================================
+ Hits         5411     5416       +5     
  Misses       3030     3030              
+ Partials      567      566       -1     
Impacted Files Coverage Δ
pkg/compose/watch.go 24.46% <87.50%> (-0.54%) ⬇️
pkg/compose/convergence.go 69.67% <100.00%> (+0.16%) ⬆️
pkg/watch/ephemeral.go 93.10% <100.00%> (ø)

... and 1 file with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@milas milas merged commit 925bc6f into docker:v2 Mar 23, 2023
@milas milas deleted the fix-watch-segfault branch March 23, 2023 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants