fix: race condition between Commit and CreateQueryContext#24508
Conversation
Ironbird - launch a networkTo use Ironbird, you can use the following commands:
Custom Load Test ConfigurationYou can provide a custom load test configuration using the `--load-test-config=` flag:Use |
📝 WalkthroughWalkthroughThe changes enhance thread safety in the baseapp module by introducing proper synchronization for state management and commit operations. The modifications refactor state access by replacing direct field references with method calls (e.g., Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Client as Client
participant BA as BaseApp
participant SM as State Mutex
participant Store as Store (Atomic)
%% Commit Flow
Client->>BA: Issue Commit Request
BA->>SM: Acquire Write Lock (setState/clearState)
BA->>BA: Perform state update operations
BA->>Store: Atomically update lastCommitInfo
BA->>SM: Release Write Lock
BA->>Client: Return Commit Response
%% Query Flow
Client->>BA: Issue Query Request
BA->>SM: Acquire Read Lock (via getState)
BA->>BA: Retrieve safe state context
BA->>SM: Release Read Lock
BA->>Client: Return Query Context
📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (6)
🧰 Additional context used🧬 Code Graph Analysis (2)baseapp/abci_test.go (3)
baseapp/baseapp.go (1)
🪛 GitHub Actions: Tests / Code Coveragebaseapp/abci_test.go[error] 202-202: TestABCI_InitChain_WithInitialHeight failed due to panic: runtime error: invalid memory address or nil pointer dereference. ⏰ Context from checks skipped due to timeout of 90000ms (2)
🔇 Additional comments (44)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
@beer-1 https://github.com/cosmos/cosmos-sdk/actions/runs/14452369048/job/40527887477?pr=24508#step:6:16 looks like a panic failure in a baseapp test |
There was a problem hiding this comment.
Copilot reviewed 7 out of 8 changed files in this pull request and generated no comments.
Files not reviewed (1)
- go.mod: Language not supported
Comments suppressed due to low confidence (3)
store/rootmulti/store.go:300
- Ensure that all accesses and updates to lastCommitInfo consistently use the atomic pointer operations to prevent any remaining race conditions.
rs.lastCommitInfo.Store(cInfo)
baseapp/baseapp.go:514
- The introduction of mutex locks for state modifications is a good step; verify that all state accesses (including read paths) are guarded appropriately to maintain consistency under concurrent loads.
app.stateMut.Lock()
baseapp/abci_test.go:2528
- [nitpick] The new race condition test is a positive addition; consider adding further tests for edge cases involving rapid state changes to fully cover concurrent access scenarios.
func TestABCI_Race_Commit_Query(t *testing.T) {
Hey @aljo242 fixed the problem |
|
@technicallyty assigning you this to evaluate if there are any performance impacts with this and if this is breaking in any unexpected ways |
|
fixed in #24655 |
Description
Replace #24392
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!in the type prefix if API or client breaking changeCHANGELOG.mdReviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.
I have...
Summary by CodeRabbit