Skip to content

fix(mempool): fix setRecheckFull/setDone race causing spurious ErrRecheckFull (backport #5837) - #5845

Merged
mergify[bot] merged 3 commits into
v0.38.xfrom
mergify/bp/v0.38.x/pr-5837
May 11, 2026
Merged

mergify[bot] merged 3 commits into
v0.38.xfrom
mergify/bp/v0.38.x/pr-5837

Conversation

@mergify

@mergify mergify Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

Fix the failing CI at https://github.com/cometbft/cometbft/actions/runs/25390468582/job/74463272144.

Two independent atomics (isRechecking, recheckFull) had a race: setDone()
cleared them in two separate stores, and setRecheckFull() (called outside
the write lock) could read stale isRechecking=true between the two stores
and overwrite the already-cleared recheckFull back to true, causing
CheckTx to spuriously return ErrRecheckFull.

Replace with a single atomic.Int32 (idle/active/full). setDone() is now
one Store(idle) with no race window; setRecheckFull() uses CAS(active→full),
so idle→full is impossible.

Add TestRecheckStateMachine to pin the state transitions and the
idle→full invariant.

PR checklist

…heckFull (#5837)

---
Fix the failing CI at
https://github.com/cometbft/cometbft/actions/runs/25390468582/job/74463272144.

Two independent atomics (`isRechecking`, `recheckFull`) had a race:
`setDone()`
cleared them in two separate stores, and `setRecheckFull()` (called
outside
the write lock) could read stale `isRechecking=true` between the two
stores
and overwrite the already-cleared `recheckFull` back to true, causing
`CheckTx` to spuriously return `ErrRecheckFull`.

Replace with a single atomic.Int32 (idle/active/full). `setDone()` is
now
one `Store(idle)` with no race window; `setRecheckFull()` uses
CAS(active→full),
so idle→full is impossible.

Add `TestRecheckStateMachine` to pin the state transitions and the
idle→full invariant.

#### PR checklist

- [x] Tests written/updated
- [x] Changelog entry added in `CHANGELOG.md`
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments

---------

Co-authored-by: mattac21 <[email protected]>
(cherry picked from commit 3b0311f)

# Conflicts:
#	CHANGELOG.md
@mergify mergify Bot added the conflicts label May 7, 2026
@mergify

mergify Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

Cherry-pick of 3b0311f has failed:

On branch mergify/bp/v0.38.x/pr-5837
Your branch is up to date with 'origin/v0.38.x'.

You are currently cherry-picking commit 3b0311fc.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   mempool/clist_mempool.go
	modified:   mempool/clist_mempool_test.go

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   CHANGELOG.md

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@greptile-apps

greptile-apps Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

PR author is not in the allowed authors list.

@mattac21
mattac21 enabled auto-merge May 11, 2026 16:23
@mergify
mergify Bot merged commit 87e5771 into v0.38.x May 11, 2026
19 checks passed
@mergify
mergify Bot deleted the mergify/bp/v0.38.x/pr-5837 branch May 11, 2026 16:30
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.

2 participants