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

100% CPU in sqlx_core::pool::inner::spawn_maintenance_tasks #3645

Open
ivan opened this issue Dec 18, 2024 · 0 comments
Open

100% CPU in sqlx_core::pool::inner::spawn_maintenance_tasks #3645

ivan opened this issue Dec 18, 2024 · 0 comments
Labels

Comments

@ivan
Copy link
Contributor

ivan commented Dec 18, 2024

Bug Description

About one in ten thousand processes, I am seeing sqlx 0.8.2 consume 100% of a core; perf top -p PID says it's in

sqlx_core::pool::inner::spawn_maintenance_tasks::_$u7b$$u7b$closure$u7d$$u7d$::h88ca82fcaec74b9d

My sqlx pools are set to use 4 connections and I connect to a PostgreSQL 16.5 with thousands of clients.

I believe the 100% CPU use happens around process exit, because I don't see errors, and all the rows I INSERT do arrive in the database.

I use

sqlx = { version = "0.8.2", default-features = false, features = ["runtime-tokio-rustls", "macros", "postgres", "rust_decimal", "uuid", "chrono", "json"] }

and set up my pool with

pub async fn new_pgpool(uri: &str) -> Result<PgPool> {
    let options: PgConnectOptions = uri.parse::<PgConnectOptions>()?
        .log_slow_statements(LevelFilter::Info, Duration::from_secs(5));
    let pool = PgPoolOptions::new()
        .acquire_timeout(Duration::from_secs(30))
        .idle_timeout(Duration::from_secs(1)) // Reduce open sessions on the server
        .max_connections(4)
        .connect_with(options).await?;
    Ok(pool)
}

I am leaving this here as a pointer to "I'm pretty sure something is wrong with spawn_maintenance_tasks", and I will try to investigate this further later if nothing seems obviously wrong with it.

Minimal Reproduction

Sorry, I'll try to provide this in 2025...

Info

  • SQLx version: 0.8.2
  • SQLx features enabled: "runtime-tokio-rustls", "macros", "postgres", "rust_decimal", "uuid", "chrono", "json"
  • Database server and version: PostgreSQL 16.5
  • Operating system: NixOS 24.05
  • rustc --version: rustc 1.84.0-nightly (ee612c45f 2024-11-19) but it has also occurred in versions from a while back
@ivan ivan added the bug label Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant