Skip to content

Conversation

@mmsqe
Copy link
Collaborator

@mmsqe mmsqe commented Jan 19, 2026

Description

to prevent goroutine leaks and hanging when scheduler doesn't complete

Closes: #25789

@codecov
Copy link

codecov bot commented Jan 19, 2026

Codecov Report

❌ Patch coverage is 94.11765% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.59%. Comparing base (8a694f0) to head (53a4582).

Files with missing lines Patch % Lines
blockstm/mvmemory.go 50.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #25793      +/-   ##
==========================================
- Coverage   70.84%   68.59%   -2.25%     
==========================================
  Files         890      889       -1     
  Lines       58024    58017       -7     
==========================================
- Hits        41106    39797    -1309     
- Misses      16918    18220    +1302     
Files with missing lines Coverage Δ
blockstm/scheduler.go 92.85% <100.00%> (+0.46%) ⬆️
blockstm/status.go 100.00% <100.00%> (ø)
blockstm/stm.go 84.61% <100.00%> (+5.30%) ⬆️
blockstm/mvmemory.go 97.26% <50.00%> (-2.74%) ⬇️

... and 38 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

s.Lock()
if s.status == StatusSuspended && s.cond != nil {
s.cond.Notify()
s.cond = nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

we need to set the status to StatusExecuting so it don't break any invariant, because the executor may still in the process of executing transaction.

Copy link
Collaborator

Choose a reason for hiding this comment

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

we also need to clear the estimation marks, otherwise, the executor still can't break out of the loop.

blockstm/stm.go Outdated
err := ctx.Err()
// canceled, wake up all suspended executors to prevent hanging
scheduler.CancelAll()
canceled := scheduler.CancelAll()
Copy link
Collaborator

Choose a reason for hiding this comment

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

If there are executors hangs, the errgroup won't finish in the first place?

Comment on lines 60 to 69
go func() {
select {
case <-ctx.Done():
canceled := scheduler.CancelAll()
for _, txn := range canceled {
mvMemory.ClearEstimates(txn)
}
case <-cancelDone:
}
}()

Check notice

Code scanning / CodeQL

Spawning a Go routine

Spawning a Go routine may be a possible source of non-determinism
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.

blockstm: need to cancel suspended executors when context is canceled

3 participants