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

Memory leak in mongodb driver version 2.7 #978

Closed
jakudlaty opened this issue Oct 21, 2023 · 7 comments
Closed

Memory leak in mongodb driver version 2.7 #978

jakudlaty opened this issue Oct 21, 2023 · 7 comments
Assignees
Labels

Comments

@jakudlaty
Copy link

jakudlaty commented Oct 21, 2023

Versions/Environment

  1. rustc 1.73.0 (cc66ad468 2023-10-03)
  2. Gentoo Linux x64, on AMD Ryzen 5950
  3. https://github.com/rust-lang/crates.io-index#[email protected]
  4. MongoDB version 7.0.2
  5. Topology standalone
  6. Empty database

Describe the bug

Memory usage grows constantly on driver version 2.7, here is simple example program:

pub use mongodb::{Client};
use mongodb::bson::doc;
use mongodb::options::ClientOptions;
use serde::{Deserialize, Serialize};

type OrderId = String;

#[derive(Serialize, Deserialize, Clone)]
pub struct OrderEntity {
    #[serde(rename = "_id")]
    pub id: OrderId,
}

#[tokio::main]
async fn main() {
    let options = ClientOptions::parse("mongodb://localhost:27017/memleak?authSource=admin&ssl=false&maxpoolsize=20").await.unwrap();
    let client = Client::with_options(options).unwrap();
    let database = client.default_database().unwrap();
    let orders = database.collection::<OrderEntity>("Orders");

    for _ in 0..10000000 {
        let _result = orders.find_one(doc! {"_id" : "12345"}, None).await.unwrap();
    }
}

my Cargo.toml kools like this:

[package]
name = "mongo-memleak-test"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tokio = { version = "1", features = ["full"] }
serde = { version = "1", features = ["derive"] }
mongodb = "=2.7.0"

The X axis on graph is measured in seconds

See the graph below:
mem-graph-2 7

On version 2.6 memory looks perfectly fine:
mem-graph-2 6

Here is the full source code of working example https://github.com/jakudlaty/mongo-memleak-test/

@jakudlaty
Copy link
Author

Here is my cargo tree when i use version 2.7

mongo-memleak-test v0.1.0 (/home/jakudlaty/Devel/mongo-memleak-test)
├── mongodb v2.7.0
│   ├── async-trait v0.1.74 (proc-macro)
│   │   ├── proc-macro2 v1.0.69
│   │   │   └── unicode-ident v1.0.12
│   │   ├── quote v1.0.33
│   │   │   └── proc-macro2 v1.0.69 (*)
│   │   └── syn v2.0.38
│   │       ├── proc-macro2 v1.0.69 (*)
│   │       ├── quote v1.0.33 (*)
│   │       └── unicode-ident v1.0.12
│   ├── base64 v0.13.1
│   ├── bitflags v1.3.2
│   ├── bson v2.7.0
│   │   ├── ahash v0.8.3
│   │   │   ├── cfg-if v1.0.0
│   │   │   ├── getrandom v0.2.10
│   │   │   │   ├── cfg-if v1.0.0
│   │   │   │   └── libc v0.2.149
│   │   │   └── once_cell v1.18.0
│   │   │   [build-dependencies]
│   │   │   └── version_check v0.9.4
│   │   ├── base64 v0.13.1
│   │   ├── bitvec v1.0.1
│   │   │   ├── funty v2.0.0
│   │   │   ├── radium v0.7.0
│   │   │   ├── tap v1.0.1
│   │   │   └── wyz v0.5.1
│   │   │       └── tap v1.0.1
│   │   ├── hex v0.4.3
│   │   ├── indexmap v1.9.3
│   │   │   └── hashbrown v0.12.3
│   │   │   [build-dependencies]
│   │   │   └── autocfg v1.1.0
│   │   ├── once_cell v1.18.0
│   │   ├── rand v0.8.5
│   │   │   ├── libc v0.2.149
│   │   │   ├── rand_chacha v0.3.1
│   │   │   │   ├── ppv-lite86 v0.2.17
│   │   │   │   └── rand_core v0.6.4
│   │   │   │       └── getrandom v0.2.10 (*)
│   │   │   └── rand_core v0.6.4 (*)
│   │   ├── serde v1.0.189
│   │   │   └── serde_derive v1.0.189 (proc-macro)
│   │   │       ├── proc-macro2 v1.0.69 (*)
│   │   │       ├── quote v1.0.33 (*)
│   │   │       └── syn v2.0.38 (*)
│   │   ├── serde_bytes v0.11.12
│   │   │   └── serde v1.0.189 (*)
│   │   ├── serde_json v1.0.107
│   │   │   ├── indexmap v2.0.2
│   │   │   │   ├── equivalent v1.0.1
│   │   │   │   └── hashbrown v0.14.2
│   │   │   ├── itoa v1.0.9
│   │   │   ├── ryu v1.0.15
│   │   │   └── serde v1.0.189 (*)
│   │   ├── time v0.3.30
│   │   │   ├── deranged v0.3.9
│   │   │   │   └── powerfmt v0.2.0
│   │   │   ├── itoa v1.0.9
│   │   │   ├── powerfmt v0.2.0
│   │   │   ├── time-core v0.1.2
│   │   │   └── time-macros v0.2.15 (proc-macro)
│   │   │       └── time-core v0.1.2
│   │   └── uuid v1.5.0
│   │       ├── getrandom v0.2.10 (*)
│   │       └── serde v1.0.189 (*)
│   ├── chrono v0.4.31
│   │   ├── iana-time-zone v0.1.58
│   │   └── num-traits v0.2.17
│   │       [build-dependencies]
│   │       └── autocfg v1.1.0
│   ├── derivative v2.2.0 (proc-macro)
│   │   ├── proc-macro2 v1.0.69 (*)
│   │   ├── quote v1.0.33 (*)
│   │   └── syn v1.0.109
│   │       ├── proc-macro2 v1.0.69 (*)
│   │       ├── quote v1.0.33 (*)
│   │       └── unicode-ident v1.0.12
│   ├── derive_more v0.99.17 (proc-macro)
│   │   ├── convert_case v0.4.0
│   │   ├── proc-macro2 v1.0.69 (*)
│   │   ├── quote v1.0.33 (*)
│   │   └── syn v1.0.109 (*)
│   │   [build-dependencies]
│   │   └── rustc_version v0.4.0
│   │       └── semver v1.0.20
│   ├── futures-core v0.3.28
│   ├── futures-executor v0.3.28
│   │   ├── futures-core v0.3.28
│   │   ├── futures-task v0.3.28
│   │   └── futures-util v0.3.28
│   │       ├── futures-core v0.3.28
│   │       ├── futures-io v0.3.28
│   │       ├── futures-macro v0.3.28 (proc-macro)
│   │       │   ├── proc-macro2 v1.0.69 (*)
│   │       │   ├── quote v1.0.33 (*)
│   │       │   └── syn v2.0.38 (*)
│   │       ├── futures-task v0.3.28
│   │       ├── memchr v2.6.4
│   │       ├── pin-project-lite v0.2.13
│   │       ├── pin-utils v0.1.0
│   │       └── slab v0.4.9
│   │           [build-dependencies]
│   │           └── autocfg v1.1.0
│   ├── futures-io v0.3.28
│   ├── futures-util v0.3.28 (*)
│   ├── hex v0.4.3
│   ├── hmac v0.12.1
│   │   └── digest v0.10.7
│   │       ├── block-buffer v0.10.4
│   │       │   └── generic-array v0.14.7
│   │       │       └── typenum v1.17.0
│   │       │       [build-dependencies]
│   │       │       └── version_check v0.9.4
│   │       ├── crypto-common v0.1.6
│   │       │   ├── generic-array v0.14.7 (*)
│   │       │   └── typenum v1.17.0
│   │       └── subtle v2.5.0
│   ├── lazy_static v1.4.0
│   ├── md-5 v0.10.6
│   │   ├── cfg-if v1.0.0
│   │   └── digest v0.10.7 (*)
│   ├── pbkdf2 v0.11.0
│   │   └── digest v0.10.7 (*)
│   ├── percent-encoding v2.3.0
│   ├── rand v0.8.5 (*)
│   ├── rustc_version_runtime v0.2.1
│   │   ├── rustc_version v0.2.3
│   │   │   └── semver v0.9.0
│   │   │       └── semver-parser v0.7.0
│   │   └── semver v0.9.0 (*)
│   │   [build-dependencies]
│   │   ├── rustc_version v0.2.3 (*)
│   │   └── semver v0.9.0 (*)
│   ├── rustls v0.21.7
│   │   ├── log v0.4.20
│   │   ├── ring v0.16.20
│   │   │   ├── libc v0.2.149
│   │   │   ├── once_cell v1.18.0
│   │   │   ├── spin v0.5.2
│   │   │   └── untrusted v0.7.1
│   │   │   [build-dependencies]
│   │   │   └── cc v1.0.83
│   │   │       └── libc v0.2.149
│   │   ├── rustls-webpki v0.101.6
│   │   │   ├── ring v0.16.20 (*)
│   │   │   └── untrusted v0.7.1
│   │   └── sct v0.7.0
│   │       ├── ring v0.16.20 (*)
│   │       └── untrusted v0.7.1
│   ├── rustls-pemfile v1.0.3
│   │   └── base64 v0.21.4
│   ├── serde v1.0.189 (*)
│   ├── serde_bytes v0.11.12 (*)
│   ├── serde_with v1.14.0
│   │   ├── serde v1.0.189 (*)
│   │   └── serde_with_macros v1.5.2 (proc-macro)
│   │       ├── darling v0.13.4
│   │       │   ├── darling_core v0.13.4
│   │       │   │   ├── fnv v1.0.7
│   │       │   │   ├── ident_case v1.0.1
│   │       │   │   ├── proc-macro2 v1.0.69 (*)
│   │       │   │   ├── quote v1.0.33 (*)
│   │       │   │   ├── strsim v0.10.0
│   │       │   │   └── syn v1.0.109 (*)
│   │       │   └── darling_macro v0.13.4 (proc-macro)
│   │       │       ├── darling_core v0.13.4 (*)
│   │       │       ├── quote v1.0.33 (*)
│   │       │       └── syn v1.0.109 (*)
│   │       ├── proc-macro2 v1.0.69 (*)
│   │       ├── quote v1.0.33 (*)
│   │       └── syn v1.0.109 (*)
│   ├── sha-1 v0.10.1
│   │   ├── cfg-if v1.0.0
│   │   ├── cpufeatures v0.2.10
│   │   └── digest v0.10.7 (*)
│   ├── sha2 v0.10.8
│   │   ├── cfg-if v1.0.0
│   │   ├── cpufeatures v0.2.10
│   │   └── digest v0.10.7 (*)
│   ├── socket2 v0.4.10
│   │   └── libc v0.2.149
│   ├── stringprep v0.1.4
│   │   ├── finl_unicode v1.2.0
│   │   ├── unicode-bidi v0.3.13
│   │   └── unicode-normalization v0.1.22
│   │       └── tinyvec v1.6.0
│   │           └── tinyvec_macros v0.1.1
│   ├── strsim v0.10.0
│   ├── take_mut v0.2.2
│   ├── thiserror v1.0.50
│   │   └── thiserror-impl v1.0.50 (proc-macro)
│   │       ├── proc-macro2 v1.0.69 (*)
│   │       ├── quote v1.0.33 (*)
│   │       └── syn v2.0.38 (*)
│   ├── tokio v1.33.0
│   │   ├── bytes v1.5.0
│   │   ├── libc v0.2.149
│   │   ├── mio v0.8.8
│   │   │   └── libc v0.2.149
│   │   ├── num_cpus v1.16.0
│   │   │   └── libc v0.2.149
│   │   ├── parking_lot v0.12.1
│   │   │   ├── lock_api v0.4.11
│   │   │   │   └── scopeguard v1.2.0
│   │   │   │   [build-dependencies]
│   │   │   │   └── autocfg v1.1.0
│   │   │   └── parking_lot_core v0.9.9
│   │   │       ├── cfg-if v1.0.0
│   │   │       ├── libc v0.2.149
│   │   │       └── smallvec v1.11.1
│   │   ├── pin-project-lite v0.2.13
│   │   ├── signal-hook-registry v1.4.1
│   │   │   └── libc v0.2.149
│   │   ├── socket2 v0.5.5
│   │   │   └── libc v0.2.149
│   │   └── tokio-macros v2.1.0 (proc-macro)
│   │       ├── proc-macro2 v1.0.69 (*)
│   │       ├── quote v1.0.33 (*)
│   │       └── syn v2.0.38 (*)
│   ├── tokio-rustls v0.24.1
│   │   ├── rustls v0.21.7 (*)
│   │   └── tokio v1.33.0 (*)
│   ├── tokio-util v0.7.9
│   │   ├── bytes v1.5.0
│   │   ├── futures-core v0.3.28
│   │   ├── futures-io v0.3.28
│   │   ├── futures-sink v0.3.28
│   │   ├── pin-project-lite v0.2.13
│   │   └── tokio v1.33.0 (*)
│   ├── trust-dns-proto v0.21.2
│   │   ├── async-trait v0.1.74 (proc-macro) (*)
│   │   ├── cfg-if v1.0.0
│   │   ├── data-encoding v2.4.0
│   │   ├── enum-as-inner v0.4.0 (proc-macro)
│   │   │   ├── heck v0.4.1
│   │   │   ├── proc-macro2 v1.0.69 (*)
│   │   │   ├── quote v1.0.33 (*)
│   │   │   └── syn v1.0.109 (*)
│   │   ├── futures-channel v0.3.28
│   │   │   └── futures-core v0.3.28
│   │   ├── futures-io v0.3.28
│   │   ├── futures-util v0.3.28 (*)
│   │   ├── idna v0.2.3
│   │   │   ├── matches v0.1.10
│   │   │   ├── unicode-bidi v0.3.13
│   │   │   └── unicode-normalization v0.1.22 (*)
│   │   ├── ipnet v2.8.0
│   │   ├── lazy_static v1.4.0
│   │   ├── log v0.4.20
│   │   ├── rand v0.8.5 (*)
│   │   ├── smallvec v1.11.1
│   │   ├── thiserror v1.0.50 (*)
│   │   ├── tinyvec v1.6.0 (*)
│   │   ├── tokio v1.33.0 (*)
│   │   └── url v2.4.1
│   │       ├── form_urlencoded v1.2.0
│   │       │   └── percent-encoding v2.3.0
│   │       ├── idna v0.4.0
│   │       │   ├── unicode-bidi v0.3.13
│   │       │   └── unicode-normalization v0.1.22 (*)
│   │       └── percent-encoding v2.3.0
│   ├── trust-dns-resolver v0.21.2
│   │   ├── cfg-if v1.0.0
│   │   ├── futures-util v0.3.28 (*)
│   │   ├── lazy_static v1.4.0
│   │   ├── log v0.4.20
│   │   ├── lru-cache v0.1.2
│   │   │   └── linked-hash-map v0.5.6
│   │   ├── parking_lot v0.12.1 (*)
│   │   ├── resolv-conf v0.7.0
│   │   │   ├── hostname v0.3.1
│   │   │   │   ├── libc v0.2.149
│   │   │   │   └── match_cfg v0.1.0
│   │   │   └── quick-error v1.2.3
│   │   ├── smallvec v1.11.1
│   │   ├── thiserror v1.0.50 (*)
│   │   ├── tokio v1.33.0 (*)
│   │   └── trust-dns-proto v0.21.2 (*)
│   ├── typed-builder v0.10.0 (proc-macro)
│   │   ├── proc-macro2 v1.0.69 (*)
│   │   ├── quote v1.0.33 (*)
│   │   └── syn v1.0.109 (*)
│   ├── uuid v1.5.0 (*)
│   └── webpki-roots v0.25.2
├── serde v1.0.189 (*)
└── tokio v1.33.0 (*)

And here is for version 2.6

mongo-memleak-test v0.1.0 (/home/jakudlaty/Devel/mongo-memleak-test)
├── mongodb v2.6.0
│   ├── async-trait v0.1.74 (proc-macro)
│   │   ├── proc-macro2 v1.0.69
│   │   │   └── unicode-ident v1.0.12
│   │   ├── quote v1.0.33
│   │   │   └── proc-macro2 v1.0.69 (*)
│   │   └── syn v2.0.38
│   │       ├── proc-macro2 v1.0.69 (*)
│   │       ├── quote v1.0.33 (*)
│   │       └── unicode-ident v1.0.12
│   ├── base64 v0.13.1
│   ├── bitflags v1.3.2
│   ├── bson v2.7.0
│   │   ├── ahash v0.8.3
│   │   │   ├── cfg-if v1.0.0
│   │   │   ├── getrandom v0.2.10
│   │   │   │   ├── cfg-if v1.0.0
│   │   │   │   └── libc v0.2.149
│   │   │   └── once_cell v1.18.0
│   │   │   [build-dependencies]
│   │   │   └── version_check v0.9.4
│   │   ├── base64 v0.13.1
│   │   ├── bitvec v1.0.1
│   │   │   ├── funty v2.0.0
│   │   │   ├── radium v0.7.0
│   │   │   ├── tap v1.0.1
│   │   │   └── wyz v0.5.1
│   │   │       └── tap v1.0.1
│   │   ├── hex v0.4.3
│   │   ├── indexmap v1.9.3
│   │   │   └── hashbrown v0.12.3
│   │   │   [build-dependencies]
│   │   │   └── autocfg v1.1.0
│   │   ├── once_cell v1.18.0
│   │   ├── rand v0.8.5
│   │   │   ├── libc v0.2.149
│   │   │   ├── rand_chacha v0.3.1
│   │   │   │   ├── ppv-lite86 v0.2.17
│   │   │   │   └── rand_core v0.6.4
│   │   │   │       └── getrandom v0.2.10 (*)
│   │   │   └── rand_core v0.6.4 (*)
│   │   ├── serde v1.0.189
│   │   │   └── serde_derive v1.0.189 (proc-macro)
│   │   │       ├── proc-macro2 v1.0.69 (*)
│   │   │       ├── quote v1.0.33 (*)
│   │   │       └── syn v2.0.38 (*)
│   │   ├── serde_bytes v0.11.12
│   │   │   └── serde v1.0.189 (*)
│   │   ├── serde_json v1.0.107
│   │   │   ├── indexmap v2.0.2
│   │   │   │   ├── equivalent v1.0.1
│   │   │   │   └── hashbrown v0.14.2
│   │   │   ├── itoa v1.0.9
│   │   │   ├── ryu v1.0.15
│   │   │   └── serde v1.0.189 (*)
│   │   ├── time v0.3.30
│   │   │   ├── deranged v0.3.9
│   │   │   │   └── powerfmt v0.2.0
│   │   │   ├── itoa v1.0.9
│   │   │   ├── powerfmt v0.2.0
│   │   │   ├── time-core v0.1.2
│   │   │   └── time-macros v0.2.15 (proc-macro)
│   │   │       └── time-core v0.1.2
│   │   └── uuid v1.5.0
│   │       ├── getrandom v0.2.10 (*)
│   │       └── serde v1.0.189 (*)
│   ├── chrono v0.4.31
│   │   ├── iana-time-zone v0.1.58
│   │   └── num-traits v0.2.17
│   │       [build-dependencies]
│   │       └── autocfg v1.1.0
│   ├── derivative v2.2.0 (proc-macro)
│   │   ├── proc-macro2 v1.0.69 (*)
│   │   ├── quote v1.0.33 (*)
│   │   └── syn v1.0.109
│   │       ├── proc-macro2 v1.0.69 (*)
│   │       ├── quote v1.0.33 (*)
│   │       └── unicode-ident v1.0.12
│   ├── derive_more v0.99.17 (proc-macro)
│   │   ├── convert_case v0.4.0
│   │   ├── proc-macro2 v1.0.69 (*)
│   │   ├── quote v1.0.33 (*)
│   │   └── syn v1.0.109 (*)
│   │   [build-dependencies]
│   │   └── rustc_version v0.4.0
│   │       └── semver v1.0.20
│   ├── futures-core v0.3.28
│   ├── futures-executor v0.3.28
│   │   ├── futures-core v0.3.28
│   │   ├── futures-task v0.3.28
│   │   └── futures-util v0.3.28
│   │       ├── futures-core v0.3.28
│   │       ├── futures-io v0.3.28
│   │       ├── futures-macro v0.3.28 (proc-macro)
│   │       │   ├── proc-macro2 v1.0.69 (*)
│   │       │   ├── quote v1.0.33 (*)
│   │       │   └── syn v2.0.38 (*)
│   │       ├── futures-task v0.3.28
│   │       ├── memchr v2.6.4
│   │       ├── pin-project-lite v0.2.13
│   │       ├── pin-utils v0.1.0
│   │       └── slab v0.4.9
│   │           [build-dependencies]
│   │           └── autocfg v1.1.0
│   ├── futures-io v0.3.28
│   ├── futures-util v0.3.28 (*)
│   ├── hex v0.4.3
│   ├── hmac v0.12.1
│   │   └── digest v0.10.7
│   │       ├── block-buffer v0.10.4
│   │       │   └── generic-array v0.14.7
│   │       │       └── typenum v1.17.0
│   │       │       [build-dependencies]
│   │       │       └── version_check v0.9.4
│   │       ├── crypto-common v0.1.6
│   │       │   ├── generic-array v0.14.7 (*)
│   │       │   └── typenum v1.17.0
│   │       └── subtle v2.5.0
│   ├── lazy_static v1.4.0
│   ├── md-5 v0.10.6
│   │   ├── cfg-if v1.0.0
│   │   └── digest v0.10.7 (*)
│   ├── pbkdf2 v0.11.0
│   │   └── digest v0.10.7 (*)
│   ├── percent-encoding v2.3.0
│   ├── rand v0.8.5 (*)
│   ├── rustc_version_runtime v0.2.1
│   │   ├── rustc_version v0.2.3
│   │   │   └── semver v0.9.0
│   │   │       └── semver-parser v0.7.0
│   │   └── semver v0.9.0 (*)
│   │   [build-dependencies]
│   │   ├── rustc_version v0.2.3 (*)
│   │   └── semver v0.9.0 (*)
│   ├── rustls v0.20.9
│   │   ├── log v0.4.20
│   │   ├── ring v0.16.20
│   │   │   ├── libc v0.2.149
│   │   │   ├── once_cell v1.18.0
│   │   │   ├── spin v0.5.2
│   │   │   └── untrusted v0.7.1
│   │   │   [build-dependencies]
│   │   │   └── cc v1.0.83
│   │   │       └── libc v0.2.149
│   │   ├── sct v0.7.0
│   │   │   ├── ring v0.16.20 (*)
│   │   │   └── untrusted v0.7.1
│   │   └── webpki v0.22.4
│   │       ├── ring v0.17.5
│   │       │   ├── getrandom v0.2.10 (*)
│   │       │   ├── libc v0.2.149
│   │       │   ├── spin v0.9.8
│   │       │   └── untrusted v0.9.0
│   │       │   [build-dependencies]
│   │       │   └── cc v1.0.83 (*)
│   │       └── untrusted v0.9.0
│   ├── rustls-pemfile v1.0.3
│   │   └── base64 v0.21.4
│   ├── serde v1.0.189 (*)
│   ├── serde_bytes v0.11.12 (*)
│   ├── serde_with v1.14.0
│   │   ├── serde v1.0.189 (*)
│   │   └── serde_with_macros v1.5.2 (proc-macro)
│   │       ├── darling v0.13.4
│   │       │   ├── darling_core v0.13.4
│   │       │   │   ├── fnv v1.0.7
│   │       │   │   ├── ident_case v1.0.1
│   │       │   │   ├── proc-macro2 v1.0.69 (*)
│   │       │   │   ├── quote v1.0.33 (*)
│   │       │   │   ├── strsim v0.10.0
│   │       │   │   └── syn v1.0.109 (*)
│   │       │   └── darling_macro v0.13.4 (proc-macro)
│   │       │       ├── darling_core v0.13.4 (*)
│   │       │       ├── quote v1.0.33 (*)
│   │       │       └── syn v1.0.109 (*)
│   │       ├── proc-macro2 v1.0.69 (*)
│   │       ├── quote v1.0.33 (*)
│   │       └── syn v1.0.109 (*)
│   ├── sha-1 v0.10.1
│   │   ├── cfg-if v1.0.0
│   │   ├── cpufeatures v0.2.10
│   │   └── digest v0.10.7 (*)
│   ├── sha2 v0.10.8
│   │   ├── cfg-if v1.0.0
│   │   ├── cpufeatures v0.2.10
│   │   └── digest v0.10.7 (*)
│   ├── socket2 v0.4.10
│   │   └── libc v0.2.149
│   ├── stringprep v0.1.4
│   │   ├── finl_unicode v1.2.0
│   │   ├── unicode-bidi v0.3.13
│   │   └── unicode-normalization v0.1.22
│   │       └── tinyvec v1.6.0
│   │           └── tinyvec_macros v0.1.1
│   ├── strsim v0.10.0
│   ├── take_mut v0.2.2
│   ├── thiserror v1.0.50
│   │   └── thiserror-impl v1.0.50 (proc-macro)
│   │       ├── proc-macro2 v1.0.69 (*)
│   │       ├── quote v1.0.33 (*)
│   │       └── syn v2.0.38 (*)
│   ├── tokio v1.33.0
│   │   ├── bytes v1.5.0
│   │   ├── libc v0.2.149
│   │   ├── mio v0.8.8
│   │   │   └── libc v0.2.149
│   │   ├── num_cpus v1.16.0
│   │   │   └── libc v0.2.149
│   │   ├── parking_lot v0.12.1
│   │   │   ├── lock_api v0.4.11
│   │   │   │   └── scopeguard v1.2.0
│   │   │   │   [build-dependencies]
│   │   │   │   └── autocfg v1.1.0
│   │   │   └── parking_lot_core v0.9.9
│   │   │       ├── cfg-if v1.0.0
│   │   │       ├── libc v0.2.149
│   │   │       └── smallvec v1.11.1
│   │   ├── pin-project-lite v0.2.13
│   │   ├── signal-hook-registry v1.4.1
│   │   │   └── libc v0.2.149
│   │   ├── socket2 v0.5.5
│   │   │   └── libc v0.2.149
│   │   └── tokio-macros v2.1.0 (proc-macro)
│   │       ├── proc-macro2 v1.0.69 (*)
│   │       ├── quote v1.0.33 (*)
│   │       └── syn v2.0.38 (*)
│   ├── tokio-rustls v0.23.4
│   │   ├── rustls v0.20.9 (*)
│   │   ├── tokio v1.33.0 (*)
│   │   └── webpki v0.22.4 (*)
│   ├── tokio-util v0.7.9
│   │   ├── bytes v1.5.0
│   │   ├── futures-core v0.3.28
│   │   ├── futures-io v0.3.28
│   │   ├── futures-sink v0.3.28
│   │   ├── pin-project-lite v0.2.13
│   │   └── tokio v1.33.0 (*)
│   ├── trust-dns-proto v0.21.2
│   │   ├── async-trait v0.1.74 (proc-macro) (*)
│   │   ├── cfg-if v1.0.0
│   │   ├── data-encoding v2.4.0
│   │   ├── enum-as-inner v0.4.0 (proc-macro)
│   │   │   ├── heck v0.4.1
│   │   │   ├── proc-macro2 v1.0.69 (*)
│   │   │   ├── quote v1.0.33 (*)
│   │   │   └── syn v1.0.109 (*)
│   │   ├── futures-channel v0.3.28
│   │   │   └── futures-core v0.3.28
│   │   ├── futures-io v0.3.28
│   │   ├── futures-util v0.3.28 (*)
│   │   ├── idna v0.2.3
│   │   │   ├── matches v0.1.10
│   │   │   ├── unicode-bidi v0.3.13
│   │   │   └── unicode-normalization v0.1.22 (*)
│   │   ├── ipnet v2.8.0
│   │   ├── lazy_static v1.4.0
│   │   ├── log v0.4.20
│   │   ├── rand v0.8.5 (*)
│   │   ├── smallvec v1.11.1
│   │   ├── thiserror v1.0.50 (*)
│   │   ├── tinyvec v1.6.0 (*)
│   │   ├── tokio v1.33.0 (*)
│   │   └── url v2.4.1
│   │       ├── form_urlencoded v1.2.0
│   │       │   └── percent-encoding v2.3.0
│   │       ├── idna v0.4.0
│   │       │   ├── unicode-bidi v0.3.13
│   │       │   └── unicode-normalization v0.1.22 (*)
│   │       └── percent-encoding v2.3.0
│   ├── trust-dns-resolver v0.21.2
│   │   ├── cfg-if v1.0.0
│   │   ├── futures-util v0.3.28 (*)
│   │   ├── lazy_static v1.4.0
│   │   ├── log v0.4.20
│   │   ├── lru-cache v0.1.2
│   │   │   └── linked-hash-map v0.5.6
│   │   ├── parking_lot v0.12.1 (*)
│   │   ├── resolv-conf v0.7.0
│   │   │   ├── hostname v0.3.1
│   │   │   │   ├── libc v0.2.149
│   │   │   │   └── match_cfg v0.1.0
│   │   │   └── quick-error v1.2.3
│   │   ├── smallvec v1.11.1
│   │   ├── thiserror v1.0.50 (*)
│   │   ├── tokio v1.33.0 (*)
│   │   └── trust-dns-proto v0.21.2 (*)
│   ├── typed-builder v0.10.0 (proc-macro)
│   │   ├── proc-macro2 v1.0.69 (*)
│   │   ├── quote v1.0.33 (*)
│   │   └── syn v1.0.109 (*)
│   ├── uuid v1.5.0 (*)
│   └── webpki-roots v0.22.6
│       └── webpki v0.22.4 (*)
├── serde v1.0.189 (*)
└── tokio v1.33.0 (*)

Please tell me if i am doing something wrong, but after downgrading driver to version 2.6 memory does not grow.

@abr-egn
Copy link
Contributor

abr-egn commented Oct 22, 2023

Hi!

I've reproduced this and have a solid lead on what's going on - I expect to have a fix in on Monday, and we'll cut a 2.7.1 release for that.

I'd also like to thank you for the most conscientious bug report I've ever seen, it made it very easy to pick up :)

@jakudlaty
Copy link
Author

You are really kind. I just tried to be as helpful as I can :)

Maybe You can share Your methodology, how to track crates / methods where the memory is allocated and never released?
I simply bisected my code to (and mocked the database) to figure out if its on database side (aka repository), or in Axum / serialization code etc. I tried to use Valgrind, but in mangled code its really hard to figure out where the bug is.
But i bet there are better ways to do it.

@abr-egn
Copy link
Contributor

abr-egn commented Oct 23, 2023

#979 should fix this :)

I don't really have any special techniques to share, unfortunately - it sounds like you did what I would have. If my first guess at the issue hadn't been correct, I probably would have tried to use https://docs.rs/dhat/latest/dhat/.

@leepa
Copy link

leepa commented Oct 31, 2023

I can confirm that #979 fixed the issue for us. However... can we please push a new version asap as the current published crate has this leak and it's quite drastic!

@abr-egn
Copy link
Contributor

abr-egn commented Oct 31, 2023

We'll be pushing a release tomorrow for this :)

@abr-egn
Copy link
Contributor

abr-egn commented Nov 1, 2023

2.7.1 with this fix is now available.

@abr-egn abr-egn closed this as completed Nov 1, 2023
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

3 participants