-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Bug Description
The connection (pool) "remembers" the query with the biggest memory size. It means when you insert some binary data (e.g. 100 MB) then it doesn't free the memory even though the data are already stored in the database.
I've tried to call persistent(false) or set various settings like max_lifetime but nothing really helped.
I've noticed the bug because my Rust app that uses sqlx through SeaORM was crashing on the server with the error "out of memory". The app uploads temporary binary data (~1-40MB) to Postgres and it allocates hundreds of MBs because of the sqlx bug until I set the maximum number of connections to a lower number with aggressive short lifetime and min_connections 0.
I've tried to debug it by myself by no luck unfortunately.
Minimal Reproduction
https://github.com/MartinKavik/sqlx-memory-debug
(instructions + a screenshot in the README)
Info
- SQLx version: 0.6
- SQLx features enabled: [ "runtime-tokio-rustls" , "postgres" ]
- Database server and version: Postgres 13.5 or newer (other DBs not tested)
- Operating system: desktop Kubuntu, server Ubuntu
rustc --version: rustc 1.67.1 (d5a82bbd2 2023-02-07)
Thank you!