-
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
Concurrent map read and map write in GRPC server #10568
Comments
Version exists is a read mutex but it seems to mutate state. We will need to change it to a mutex. |
This has been fixed in a new release of iavl. |
Is this resolved in the new Cosmos? I am on Cosmos 0.44.x and see this happening.
|
Hi @njmurarka, a few things:
|
Hi @alexanderbez @tac0turtle, we got a report from a keplr node that this is happening using cosmos-sdk v0.46.7 and iavl v0.19.4 The issue is on the UnsavedFastIterator. Below is the stack trace
|
I managed to reproduce the error using concurrency on this test, replacing these lines for // first delegator withdraws
wg.Add(1)
go func() {
defer wg.Done()
expRewards := sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(initial*3/4))}
bankKeeper.EXPECT().SendCoinsFromModuleToAccount(ctx, disttypes.ModuleName, addr, expRewards)
_, err = distrKeeper.WithdrawDelegationRewards(ctx, addr, valAddr)
require.NoError(t, err)
}()
// second delegator withdraws
wg.Add(1)
go func() {
defer wg.Done()
expRewards := sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(initial*1/4))}
bankKeeper.EXPECT().SendCoinsFromModuleToAccount(ctx, disttypes.ModuleName, sdk.AccAddress(valConsAddr1), expRewards)
_, err = distrKeeper.WithdrawDelegationRewards(ctx, sdk.AccAddress(valConsAddr1), valAddr)
require.NoError(t, err)
}()
wg.Wait() I ran it multiple times, sometimes passes, and sometimes panics.
While doing this, also observed other concurrency issues:
|
All these seem to be related to concurrent read and write operations to the I tried adding a mutex and use the lock when these operations happen and seems to solve the issue. |
I have no idea if these methods are supposed to be thread-safe or not. |
Summary of Bug
Concurrent map read and map write
sometimes kills application when accessing GRPC server. Related to #8591, #8549Version
github.com/cosmos/cosmos-sdk v0.44.3
For Admin Use
The text was updated successfully, but these errors were encountered: