-
Notifications
You must be signed in to change notification settings - Fork 1.4k
OOM during insertion #1507
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
Comments
SQLx transparently caches prepared statements and we don't currently have an eviction policy, so yeah if you're generating unique queries in a loop it's definitely gonna look like an egregious memory leak. Try this: sqlx::query(&q).persistent(false).execute(&mut trans).await?; |
I see. With How can I set |
It's a known issue: #1503 |
Well, I made a PR. Hope that it will fix. |
I found the performance issue regarding sqlite was already described in here #1481. |
I think this simple insertions should complete without OOM but in my machine with 32GB mem the program is killed in 5 or 10 minutes. You will see the program is eating a lot of memory.
Here is my reproducer. You can
sh run.sh
but may not reproduce if your machine has lot of RAM (>= 32GB).https://github.com/akiradeveloper/sqlx-leak-repro
I think this is a bug because the same code with rusqlite 0.25 and 0.26 doesn't have the problem at all. With rusqlite, the memory usage is stable and low. I suspect memory leak with sqlx.
Also, I have noticed that there is a huge difference in terms of the performance characteristic between sqlx and rusqlite. In my env, sqlx version can complete with N=100000 but slower than rusqlite version like x2. Maybe, this is due to memory leak or lack of optimization in sqlite impl.
The text was updated successfully, but these errors were encountered: