use std::{sync::Arc, time::Duration};
use object_store::memory::InMemory;
const CYCLES: usize = 300;
const CLOSE_TIMEOUT: Duration = Duration::from_secs(10);
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
#[ignore = "upstream reproducer: runs until it wedges, and may need killing"]
#[allow(clippy::unwrap_used)]
async fn slatedb_close_can_hang_on_a_multi_thread_runtime() {
let object_store: Arc<InMemory> = Arc::new(InMemory::new());
let settings = slatedb::config::Settings {
flush_interval: Some(Duration::from_millis(1)),
..Default::default()
};
for cycle in 0..CYCLES {
let db = slatedb::Db::builder("", object_store.clone())
.with_settings(settings.clone())
.build()
.await
.unwrap();
db.put(b"k", format!("v{cycle}").as_bytes()).await.unwrap();
if tokio::time::timeout(CLOSE_TIMEOUT, db.close())
.await
.is_err()
{
eprintln!("close wedged on cycle {cycle} of {CYCLES}");
return;
}
}
panic!(
"{CYCLES} open/write/close cycles all completed: the upstream close hang looks fixed, \
so drop this test and the multi-threaded caveat it documents"
);
}