Skip to content
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]: baseapp create query context has mutex contention on IAVL versioning #23695

Open
1 task done
ValarDragon opened this issue Feb 13, 2025 · 1 comment
Open
1 task done
Labels

Comments

@ValarDragon
Copy link
Contributor

ValarDragon commented Feb 13, 2025

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

Image

We currently see nodes crashing under too many threads, when getting many queries. We are getting over 20% of the goroutines blocked on mutexes in IAVL just for seeing if we have the relevant version. (2878 goroutines stuck here)

But these are queries that don't specify a height, so this is an unneeded contention in the first place. Furthermore, many of the queries themselves are blocked on IAVL reads, so this significantly exacerbates the problem here, leading to crashes + all queries processing too slowly.

We should get query fetching the IAVL version to have lock-free mechanisms. E.g. a CAS operation to fetch a "supported versions" within IAVL, that we update with a CAS op on new block/prune. Or maybe just a CAS op to handle this for getting latest version.

Cosmos SDK Version

0.50

How to reproduce?

Run many slightly slow queries, e.g. cosmwasm queries. You are then liable to too many threads causing a node to crash. If you profile via pprof to get where the threads are, you see graphs as above.

@tac0turtle
Copy link
Member

is this on iavl or the underlying db? goleveldb is not well optimised for workloads for single writer multiple reader. Have you tried testing this with pebbledb?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 📋 Backlog
Development

No branches or pull requests

2 participants