-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[Bug]: race condition between baseapp.Commit
and baseapp.CreateQueryContext
#22650
Labels
Comments
11 tasks
beer-1
changed the title
[Bug]: race condition in root multi store
[Bug]: race condition between Nov 26, 2024
rs.lastCommitInfo
baseapp.Commit
and ‘baseapp.CreateQueryContext’
beer-1
changed the title
[Bug]: race condition between
[Bug]: race condition between Nov 26, 2024
baseapp.Commit
and ‘baseapp.CreateQueryContext’baseapp.Commit
and baseapp.CreateQueryContext
another race condition
|
test code I used (run this with race detector) func TestABCI_Race_Commit_Query(t *testing.T) {
suite := NewBaseAppSuite(t, baseapp.SetChainID("test-chain-id"))
app := suite.baseApp
_, err := app.InitChain(&abci.RequestInitChain{
ChainId: "test-chain-id",
ConsensusParams: &cmtproto.ConsensusParams{Block: &cmtproto.BlockParams{MaxGas: 5000000}},
InitialHeight: 1,
})
require.NoError(t, err)
_, err = app.Commit()
require.NoError(t, err)
counter := atomic.Uint64{}
counter.Store(0)
ctx, cancel := context.WithCancel(context.Background())
queryCreator := func() {
for {
select {
case <-ctx.Done():
return
default:
_, err := app.CreateQueryContext(0, false)
require.NoError(t, err)
counter.Add(1)
}
}
}
for i := 0; i < 100; i++ {
go queryCreator()
}
for i := 0; i < 1000; i++ {
_, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1})
require.NoError(t, err)
_, err = app.Commit()
require.NoError(t, err)
}
cancel()
require.Equal(t, int64(1001), app.GetContextForCheckTx(nil).BlockHeight())
} |
thank you for the issue, would you want to open a pull request on the sdk to add the test and a proposed fix? |
Okay, let me try it by EoW |
12 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there an existing issue for this?
What happened?
We found race condition
rs.lastCommitInfo
betweenbaseapp.CreateQueryContext
andbaseapp.Commit
.case 1.
case 2.
see full logs
As I know, comet has entire lock between commit and query but GRPC still in this race condition risk I guess
cosmos-sdk/baseapp/grpcserver.go
Line 49 in 6dc6e8b
Cosmos SDK Version
0.50
How to reproduce?
maybe hitting tons of grpc queries at block commit timing?
The text was updated successfully, but these errors were encountered: