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

Release/v20.11 - fix(ludicrous): Fix logical race in concurrent execution of mutations… #7309

Merged
merged 1 commit into from
Jan 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion worker/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ func (e *executor) processMutationCh(ctx context.Context, ch chan *subMutation)
graph: g,
}

isDependent := false
g.Lock()
for c := range conflicts {
l, ok := g.conflicts[c]
Expand All @@ -236,6 +237,7 @@ func (e *executor) processMutationCh(ctx context.Context, ch chan *subMutation)
for _, dependent := range l {
_, ok := dependent.dependentMutations[m.sm.startTs]
if !ok {
isDependent = true
atomic.AddInt64(&m.inDeg, 1)
dependent.dependentMutations[m.sm.startTs] = m
}
Expand All @@ -246,7 +248,10 @@ func (e *executor) processMutationCh(ctx context.Context, ch chan *subMutation)
}
g.Unlock()

if atomic.LoadInt64(&m.inDeg) == 0 {
// If this mutation doesn't depend on any other mutation then process it right now.
// Otherwise, don't process it. It will be called for processing when the last mutation on
// which it depends is completed.
if !isDependent {
x.Check(e.throttle.Do())
go e.worker(m)
}
Expand Down