djc / bb8

Full-featured async (tokio-based) postgres connection pool (like r2d2)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Attempt to subtract with overflow, new version 8.2

Sagebati opened this issue · comments

Hi,

We come across this bug in when upgrading to 8.2

attempt to subtract with overflow
thread 'tokio-runtime-worker' panicked at /home/sam/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bb8-0.8.2/src/internals.rs:98:9

In our development environment we also tiggered errors when trying to get connections from the pool. Then the pool was unusable and required restarting the service.

I think it's related to #186

I have the parking lot feature enabled

Sorry for the regression!

Do you have/can you get a full backtrace?

Here is a half of the backtrace before it goes into axum and tokio. It was compiled in debug.

I didn't though about it, but in our dev environement, I think it's the same bug just that the overflow check is removed in release.

thread 'tokio-runtime-worker' panicked at /home/sam/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bb8-0.8.2/src/internals.rs:98:9:
attempt to subtract with overflow
stack backtrace:
   0:     0x5cd0de731d5c - std::backtrace_rs::backtrace::libunwind::trace::ha637c64ce894333a
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x5cd0de731d5c - std::backtrace_rs::backtrace::trace_unsynchronized::h47f62dea28e0c88d
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x5cd0de731d5c - std::sys_common::backtrace::_print_fmt::h9eef0abe20ede486
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x5cd0de731d5c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hed7f999df88cc644
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x5cd0de75fb20 - core::fmt::rt::Argument::fmt::h1539a9308b8d058d
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/fmt/rt.rs:142:9
   5:     0x5cd0de75fb20 - core::fmt::write::h3a39390d8560d9c9
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/fmt/mod.rs:1120:17
   6:     0x5cd0de72e7ff - std::io::Write::write_fmt::h5fc9997dfe05f882
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/io/mod.rs:1762:15
   7:     0x5cd0de731b44 - std::sys_common::backtrace::_print::h894006fb5c6f3d45
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x5cd0de731b44 - std::sys_common::backtrace::print::h23a2d212c6fff936
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x5cd0de7334c7 - std::panicking::default_hook::{{closure}}::h8a1d2ee00185001a
  10:     0x5cd0de73322f - std::panicking::default_hook::h6038f2eba384e475
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:292:9
  11:     0x5cd0dd3cbca3 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hbff4436607fa2d6c
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/alloc/src/boxed.rs:2021:9
  12:     0x5cd0dd3cc295 - <sentry_panic::PanicIntegration as sentry_core::integration::Integration>::setup::{{closure}}::{{closure}}::h825edb0b14d80f30
                               at /home/sam/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sentry-panic-0.32.2/src/lib.rs:71:17
  13:     0x5cd0de733b48 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h1f8f335eaa9cfaee
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/alloc/src/boxed.rs:2021:9
  14:     0x5cd0de733b48 - std::panicking::rust_panic_with_hook::h2b5517d590cab22e
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:783:13
  15:     0x5cd0de733869 - std::panicking::begin_panic_handler::{{closure}}::h233112c06e0ef43e
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:649:13
  16:     0x5cd0de732226 - std::sys_common::backtrace::__rust_end_short_backtrace::h6e893f24d7ebbff8
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:170:18
  17:     0x5cd0de733602 - rust_begin_unwind
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:645:5
  18:     0x5cd0de75d365 - core::panicking::panic_fmt::hbf0e066aabfa482c
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:72:14
  19:     0x5cd0de75d403 - core::panicking::panic::h195fc2a96298d4c3
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:127:5
  20:     0x5cd0dcc02cf7 - bb8::internals::PoolInternals<M>::dropped::h776a4511666d13a4
                               at /home/sam/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bb8-0.8.2/src/internals.rs:98:9
  21:     0x5cd0dc600d46 - bb8::inner::PoolInner<M>::put_back::h0a5409b5db1bb80f
                               at /home/sam/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bb8-0.8.2/src/inner.rs:141:33
  22:     0x5cd0dca72078 - <bb8::api::PooledConnection<M> as core::ops::drop::Drop>::drop::h8daa834c200fe505
                               at /home/sam/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bb8-0.8.2/src/api.rs:432:9
  23:     0x5cd0dc9e6f73 - core::ptr::drop_in_place<bb8::api::PooledConnection<diesel_async::pooled_connection::AsyncDieselConnectionManager<diesel_async::pg::AsyncPgConnection>>>::hc907253b11a55c10
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ptr/mod.rs:498:1
  24:     0x5cd0dc4a18a6 - bb8::api::Pool<M>::get_owned::{{closure}}::had50cafc7d21fe06
                               at /home/sam/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bb8-0.8.2/src/api.rs:67:5
  25:     0x5cd0dc29084a - app::state::<impl axum_core::extract::FromRequestParts<app::state::AppState> for app::db::Db>::from_request_parts::{{closure}}::h4275da723d6decfd
                               at /home/sam/src/rust/app-v3/src/state.rs:60:14
  26:     0x5cd0dc1ef71d - <core::pin::Pin<P> as core::future::future::Future>::poll::h5f077dee6d198e43
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/future/future.rs:125:9
  27:     0x5cd0dc74c1ec - <T as axum_core::extract::FromRequest<S,axum_core::extract::private::ViaParts>>::from_request::{{closure}}::hbe583de6ccd582b3
                               at /home/sam/.cargo/registry/src/index.crates.io-6f17d22bba15001f/axum-core-0.4.3/src/extract/mod.rs:98:53
  28:     0x5cd0dc1ef71d - <core::pin::Pin<P> as core::future::future::Future>::poll::h5f077dee6d198e43
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/future/future.rs:125:9

That's great, thanks! Let me look into this.

Please have a look at #189 -- I think this should fix the issue.

This indeed resolved the issue in local at least