-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
engine: fix race in concatenate #15454
Conversation
Signed-off-by: Vicent Marti <[email protected]>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #15454 +/- ##
=======================================
Coverage 65.64% 65.65%
=======================================
Files 1563 1563
Lines 194389 194395 +6
=======================================
+ Hits 127602 127622 +20
+ Misses 66787 66773 -14 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Vicent Marti <[email protected]> Signed-off-by: Dirkjan Bussink <[email protected]>
3760f7f
to
7cab524
Compare
for slices.Contains(rest, nil) { | ||
condFields.Wait() | ||
} | ||
muFields.Unlock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why didn't y'all use the lock ... defer unlock
pattern? That way you call unlock once at line 289 instead of 3 times in various places. And it's future-proof.
Nice work, btw 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That wouldn't be correct. The lock needs to be released before we call callback
or we'd deadlock, so using a defer
doesn't work in 2 of the cases.
Description
Race in concatenate spotted by @GuptaManan100.
Upon review, we can see that there are two races in this helper. The first one is not locking the
muFields
mutex early enough: we want to lock as soon as we enter the function because a pause between the firstif
and the lock can cause a race. The second one is more obvious: thefieldTypes
field needs to be written to with the lock being held.The fixed code is slightly more linear but I don't think that's gonna be a performance regression, and either way it needs to be linear for correctness.
Related Issue(s)
Concatenate
Engine #15434Checklist
Deployment Notes