xacrimon / dashmap

Blazing fast concurrent HashMap for Rust.
MIT License
2.84k stars 140 forks source link

Deadlocking when calling `DashMap::shrink_to_fit()` on version `6.0.0` #304

Closed JesusGuzmanJr closed 1 week ago

JesusGuzmanJr commented 2 weeks ago

The older version of dashmap crate was working fine without deadlock.

Cargo.toml

[package]
edition = "2021"
name = "deadlock"
version = "0.1.0"

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

[dependencies]
dashmap = "5.5.3"

main.rs

fn main() {
    let map = dashmap::DashMap::new();
    map.insert("hello", "world");
    map.shrink_to_fit();
    println!("done shrinking");
}

Terminal output:

jesus@MacBook:~/Developer/deadlock|main⚡ ⇒  cargo run
   Compiling deadlock v0.1.0 (/Users/jesus/Developer/deadlock)
    Finished dev [unoptimized + debuginfo] target(s) in 0.19s
     Running `target/debug/deadlock`
done shrinking

When I update to the lates 6.0.0 version, the Dashmap::shrink_to_fit() method deadlocks. Cargo.toml

[package]
edition = "2021"
name = "deadlock"
version = "0.1.0"

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

[dependencies]
dashmap = "6.0.0"

main.rs left unchanged.

Terminal output:

jesus@MacBook:~/Developer/deadlock|main⚡ ⇒  cargo run
   Compiling deadlock v0.1.0 (/Users/jesus/Developer/deadlock)
    Finished dev [unoptimized + debuginfo] target(s) in 0.34s
     Running `target/debug/deadlock`

Is there a regression or am I misusing the method?

Thanks, Jesus Guzman, Jr.

xacrimon commented 1 week ago

Hey, thanks. v6.0.0 is yanked. Investigating this now.

xacrimon commented 1 week ago

I think I've got a fix but expect 2-3 days until I can release a 6.0.1 patch to resolve this issue.

JesusGuzmanJr commented 1 week ago

Thanks for the speedy response. Dashmap is a great crate btw!

xacrimon commented 1 week ago

Now fixed in v6.0.1, which has just been released.