sled
sled copied to clipboard
Concurrent Tree::flush_async deadlocks on v0.34.6 (latest release)
rustc 1.50.0 (cb75ad5db 2021-02-10) sled v0.34.6 (latest release) on platform x86_64-pc-windows-msvc and x86_64-apple-darwin
Concurrently calling flush_async on the same tree causes deadlock. A minimal example:
use futures::{
stream::{self, StreamExt},
FutureExt,
};
use std::env::temp_dir;
#[tokio::main]
async fn main() -> sled::Result<()> {
let db = sled::open(temp_dir())?;
let sets = (0..100).map(|i| {
let db = db.clone();
async move {
db.insert(&[i], vec![0])?;
db.flush_async().await?;
Ok::<(), sled::Error>(())
}
});
stream::iter(sets)
.for_each_concurrent(None, |fut| fut.map(|_| ()))
.await;
Ok(())
}
dependencies:
[dependencies]
futures = "0.3.13"
sled = "0.34.6"
tokio = { version = "1.3.0", features = ["full"] }
However the program above won't deadlock on main, bisect shows 61803984dc1cd8c35a3d537c2a7f5538fa659fac has fixed it.
For me, this only seems to happen when compiling in release mode, and not in debug mode.
Using main does indeed fix this issue.
@spacejam this has "fixed in main branch" on this issue for almost a year, can this issue be closed, or is it not solved?
Perhaps a new release of sled with the fix included would be nice, so that new users don't run into this anymore?