From 7262d5c884bf756b70a8d115d75a5e11e98c9a54 Mon Sep 17 00:00:00 2001 From: Jordan Santell Date: Fri, 28 Jul 2023 18:58:43 -0700 Subject: [PATCH] feat: Synchronously flush sled DB rather than using sled::Tree::flush_async, which can cause deadlocks. Fixes #403 (#540) --- rust/noosphere-storage/src/implementation/native.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rust/noosphere-storage/src/implementation/native.rs b/rust/noosphere-storage/src/implementation/native.rs index b6d10f4fe..d54eb41be 100644 --- a/rust/noosphere-storage/src/implementation/native.rs +++ b/rust/noosphere-storage/src/implementation/native.rs @@ -85,7 +85,11 @@ impl Store for NativeStore { /// Flushes pending writes if there are any async fn flush(&self) -> Result<()> { - self.db.flush_async().await?; + // `flush_async()` can deadlock when simultaneous calls are performed. + // This occurs often in tests and fixed in `sled`'s main branch, + // but no cargo release since 2021. + // https://github.com/spacejam/sled/issues/1308 + self.db.flush().map_err(anyhow::Error::from)?; Ok(()) } }