π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
vecdb: switch writer lock to std file locking on a sidecar
laurenspriembcb5c61c9cb3
diff --git a/rust/Cargo.lock b/rust/Cargo.lockindex 5d534c798a..309fb08e40 100644--- a/rust/Cargo.lock+++ b/rust/Cargo.lock@@ -2672,7 +2672,6 @@ dependencies = ["html-escape","image","imageproc",- "libc","log","nalgebra 0.33.3","once_cell",@@ -2689,7 +2688,6 @@ dependencies = ["url","usearch","wide",- "windows-sys 0.61.2",][[package]]diff --git a/rust/crates/ml/Cargo.toml b/rust/crates/ml/Cargo.tomlindex e70fa5eab1..e13c70c9fc 100644--- a/rust/crates/ml/Cargo.toml+++ b/rust/crates/ml/Cargo.toml@@ -28,16 +28,6 @@ thiserror.workspace = trueusearch = { version = "=2.21.4", optional = true }wide = "0.7"-[target.'cfg(unix)'.dependencies]-libc = "0.2"--[target.'cfg(windows)'.dependencies]-windows-sys = { version = "0.61", features = [- "Win32_Foundation",- "Win32_Storage_FileSystem",- "Win32_System_IO",-] }-# Cargokit sets ORT_LIB_PATH to Ente's verified iOS archive.[target.'cfg(target_os = "ios")'.dependencies]ort = { workspace = true, features = [diff --git a/rust/crates/ml/docs/adr/0001-vecdb-durable-log-plus-derived-graph.md b/rust/crates/ml/docs/adr/0001-vecdb-durable-log-plus-derived-graph.mdindex 8eebdce3f4..a75ed79dc7 100644--- a/rust/crates/ml/docs/adr/0001-vecdb-durable-log-plus-derived-graph.md+++ b/rust/crates/ml/docs/adr/0001-vecdb-durable-log-plus-derived-graph.md@@ -10,13 +10,13 @@ We replaced usearch (C++ under the hood, broken on the napi desktop toolchain, r## Consequences-- One caller-visible path maps to two files: `<path>` (log) and `<path>.graph` (snapshot); the Rust layer owns both, consumers never see the sidecar.+- One caller-visible path maps to three files: `<path>` (log), `<path>.graph` (snapshot), and `<path>.lock` (writer-lock sidecar); the Rust layer owns all three, consumers never see the sidecars.- Snapshots are written lazily (mutation threshold + quiet-gap debounce + hard cap), on compaction, on explicit flush, and on open after tail replay β so a killed process pays at most one bounded replay at next open.- Deletes are tombstones; dead entries are compacted away (log rewrite + graph rebuild) past a ~10% dead ratio with a small absolute floor.- Exactly one writer instance per index file, enforced by an OS advisory lock; read-only opens hold no lock and no fds, and see a point-in-time view β which is what makes rename-based compaction safe on Windows.- Single metric (inner product on L2-normalized vectors, distance = 1 β dot) and single scalar (f32) are hardcoded; the file header carries scalar/metric tags and the distance kernel sits behind one internal seam so smaller scalars (f16/i8) can be added without a format break.- Keys are strings (non-empty UTF-8, β€ 256 bytes), not integers: file/face/cluster IDs are used directly, which clears the way to retire the four AUTOINCREMENT key-mapping tables the app kept in sqlite solely for usearch's u64 keys once vecdb replaces usearch. Internally keys are interned to u32 slots; the graph, arena, and log replay speak slots.- Vectors live on disk as raw little-endian f32 payloads in the framed log records, and in memory in a chunked, 32-byte-aligned arena (chunks of SIMD lanes; free-list slot reuse; growth never reallocates existing chunks). Memory-mapping the log was rejected: it breaks wasm compatibility, fights rename-based compaction on Windows, and framed records give no alignment guarantee.-- vecdb is layered as an IO-free core (graph, arena, SIMD kernels β wasm32-compatible) beneath a native-only storage layer (fs, fsync, locking). The writer lock is hand-rolled (`flock` on unix, `LockFileEx` on Windows) rather than a crate: with `wide`, `crc32fast`, `libc`, and `windows-sys` already in the dependency tree, vecdb adds zero new Cargo.lock entries.+- vecdb is layered as an IO-free core (graph, arena, SIMD kernels β wasm32-compatible) beneath a native-only storage layer (fs, fsync, locking). The writer lock is std file locking (`File::try_lock`) on the `<path>.lock` sidecar β no `libc`, no `windows-sys` β and is held continuously across compaction, so there is never an unlock window; locking the sidecar rather than the log keeps Windows whole-file lock semantics away from readers and log renames. With `wide` and `crc32fast` already in the dependency tree, vecdb adds zero new Cargo.lock entries.- usearch stays in the tree, feature-gated, while vecdb runs as a parallel engine for internal users; removal is a separate later decision.- Derived-state failures degrade instead of failing writes: snapshot and compaction errors are logged as warnings and never fail an acknowledged write, open never fails for snapshot reasons, and only an explicit `flush()` surfaces snapshot errors to the caller.diff --git a/rust/crates/ml/src/vecdb/lock.rs b/rust/crates/ml/src/vecdb/lock.rsindex 69837f7f13..2cba195605 100644--- a/rust/crates/ml/src/vecdb/lock.rs+++ b/rust/crates/ml/src/vecdb/lock.rs@@ -1,132 +1,136 @@-use std::fs::File;-use std::path::Path;+use std::fs::{File, TryLockError};+use std::path::{Path, PathBuf};use super::VecDbError;-pub(crate) fn lock_exclusive(file: &File, path: &Path) -> Result<(), VecDbError> {- if try_lock(file) {- return Ok(());- }- let error = std::io::Error::last_os_error();- if error.raw_os_error() == Some(WOULD_BLOCK_CODE) {- return Err(VecDbError::Locked(path.to_path_buf()));- }- Err(VecDbError::Io {- path: path.to_path_buf(),- source: error,- })+const ACQUIRE_ATTEMPTS: usize = 8;++#[derive(Debug)]+pub(crate) struct WriterLock {+ _file: File,}-#[cfg(unix)]-const WOULD_BLOCK_CODE: i32 = libc::EWOULDBLOCK;+impl WriterLock {+ pub(crate) fn acquire(log_path: &Path) -> Result<Self, VecDbError> {+ let sidecar = lock_path(log_path);+ for _ in 0..ACQUIRE_ATTEMPTS {+ let file = open_sidecar(&sidecar)?;+ match file.try_lock() {+ Ok(()) => {+ if lock_is_on_the_linked_sidecar(&file, &sidecar)? {+ return Ok(Self { _file: file });+ }+ }+ Err(TryLockError::WouldBlock) => {+ return Err(VecDbError::Locked(log_path.to_path_buf()));+ }+ Err(TryLockError::Error(source)) => return Err(VecDbError::io(&sidecar, source)),+ }+ }+ Err(VecDbError::Locked(log_path.to_path_buf()))+ }+}-#[cfg(unix)]-fn try_lock(file: &File) -> bool {- use std::os::fd::AsRawFd;+pub(crate) fn lock_path(log_path: &Path) -> PathBuf {+ let mut extended = log_path.as_os_str().to_os_string();+ extended.push(".lock");+ PathBuf::from(extended)+}- unsafe { libc::flock(file.as_raw_fd(), libc::LOCK_EX | libc::LOCK_NB) == 0 }+fn open_sidecar(sidecar: &Path) -> Result<File, VecDbError> {+ File::options()+ .read(true)+ .write(true)+ .create(true)+ .truncate(false)+ .open(sidecar)+ .map_err(|source| VecDbError::io(sidecar, source))}-#[cfg(windows)]-const WOULD_BLOCK_CODE: i32 = windows_sys::Win32::Foundation::ERROR_LOCK_VIOLATION as i32;--#[cfg(windows)]-const LOCK_BYTE_OFFSET: u64 = u64::MAX - 1;--#[cfg(windows)]-fn try_lock(file: &File) -> bool {- use std::os::windows::io::AsRawHandle;-- use windows_sys::Win32::Storage::FileSystem::{- LOCKFILE_EXCLUSIVE_LOCK, LOCKFILE_FAIL_IMMEDIATELY, LockFileEx,- };- use windows_sys::Win32::System::IO::OVERLAPPED;-- let mut overlapped: OVERLAPPED = unsafe { std::mem::zeroed() };- overlapped.Anonymous.Anonymous.Offset = LOCK_BYTE_OFFSET as u32;- overlapped.Anonymous.Anonymous.OffsetHigh = (LOCK_BYTE_OFFSET >> 32) as u32;- unsafe {- LockFileEx(- file.as_raw_handle(),- LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY,- 0,- 1,- 0,- &mut overlapped,- ) != 0+#[cfg(unix)]+fn lock_is_on_the_linked_sidecar(file: &File, sidecar: &Path) -> Result<bool, VecDbError> {+ use std::io::ErrorKind;+ use std::os::unix::fs::MetadataExt;++ let held = file+ .metadata()+ .map_err(|source| VecDbError::io(sidecar, source))?;+ match std::fs::metadata(sidecar) {+ Ok(linked) => Ok(linked.dev() == held.dev() && linked.ino() == held.ino()),+ Err(error) if error.kind() == ErrorKind::NotFound => Ok(false),+ Err(source) => Err(VecDbError::io(sidecar, source)),}}+#[cfg(not(unix))]+fn lock_is_on_the_linked_sidecar(_file: &File, _sidecar: &Path) -> Result<bool, VecDbError> {+ Ok(true)+}+#[cfg(test)]mod tests {- use std::fs::File;- use std::path::Path;-use tempfile::TempDir;use super::*;- fn open_rw(path: &Path) -> File {- File::options()- .read(true)- .write(true)- .create(true)- .truncate(false)- .open(path)- .unwrap()+ #[test]+ fn lock_path_appends_the_lock_extension() {+ assert_eq!(+ lock_path(Path::new("/a/vectors")),+ Path::new("/a/vectors.lock")+ );+ assert_eq!(+ lock_path(Path::new("/a/vectors.db")),+ Path::new("/a/vectors.db.lock")+ );}#[test]- fn locks_a_fresh_file() {+ fn acquire_creates_and_locks_the_sidecar() {let dir = TempDir::new().unwrap();- let path = dir.path().join("log");- let file = open_rw(&path);- assert!(lock_exclusive(&file, &path).is_ok());+ let log_path = dir.path().join("log");+ let _guard = WriterLock::acquire(&log_path).unwrap();+ assert!(lock_path(&log_path).exists());+ assert!(!log_path.exists());}#[test]- fn second_handle_on_the_same_path_conflicts() {+ fn second_acquire_on_the_same_path_reports_the_log_path() {let dir = TempDir::new().unwrap();- let path = dir.path().join("log");- let holder = open_rw(&path);- lock_exclusive(&holder, &path).unwrap();- let contender = open_rw(&path);- let error = lock_exclusive(&contender, &path).unwrap_err();- assert!(matches!(error, VecDbError::Locked(locked) if locked == path));+ let log_path = dir.path().join("log");+ let _holder = WriterLock::acquire(&log_path).unwrap();+ let error = WriterLock::acquire(&log_path).unwrap_err();+ assert!(matches!(error, VecDbError::Locked(locked) if locked == log_path));}#[test]- fn closing_the_holding_handle_releases_the_lock() {+ fn dropping_the_guard_releases_the_lock() {let dir = TempDir::new().unwrap();- let path = dir.path().join("log");- let holder = open_rw(&path);- lock_exclusive(&holder, &path).unwrap();+ let log_path = dir.path().join("log");+ let holder = WriterLock::acquire(&log_path).unwrap();drop(holder);- let successor = open_rw(&path);- assert!(lock_exclusive(&successor, &path).is_ok());+ assert!(WriterLock::acquire(&log_path).is_ok());}#[test]- fn held_lock_does_not_block_reads_or_copies_through_other_handles() {+ fn distinct_paths_lock_independently() {let dir = TempDir::new().unwrap();- let path = dir.path().join("log");- std::fs::write(&path, b"payload").unwrap();- let holder = open_rw(&path);- lock_exclusive(&holder, &path).unwrap();- assert_eq!(std::fs::read(&path).unwrap(), b"payload");- let copy_path = dir.path().join("copy");- std::fs::copy(&path, ©_path).unwrap();- assert_eq!(std::fs::read(©_path).unwrap(), b"payload");+ let _first = WriterLock::acquire(&dir.path().join("first")).unwrap();+ assert!(WriterLock::acquire(&dir.path().join("second")).is_ok());}+ #[cfg(unix)]#[test]- fn distinct_paths_do_not_conflict() {+ fn unlinking_the_sidecar_orphans_the_held_lock_and_frees_the_path() {let dir = TempDir::new().unwrap();- let first_path = dir.path().join("first");- let second_path = dir.path().join("second");- let first = open_rw(&first_path);- let second = open_rw(&second_path);- lock_exclusive(&first, &first_path).unwrap();- assert!(lock_exclusive(&second, &second_path).is_ok());+ let log_path = dir.path().join("log");+ let sidecar = lock_path(&log_path);+ let orphaned = WriterLock::acquire(&log_path).unwrap();+ std::fs::remove_file(&sidecar).unwrap();+ assert!(!lock_is_on_the_linked_sidecar(&orphaned._file, &sidecar).unwrap());+ let successor = WriterLock::acquire(&log_path).unwrap();+ assert!(lock_is_on_the_linked_sidecar(&successor._file, &sidecar).unwrap());+ let error = WriterLock::acquire(&log_path).unwrap_err();+ assert!(matches!(error, VecDbError::Locked(locked) if locked == log_path));}}diff --git a/rust/crates/ml/src/vecdb/store.rs b/rust/crates/ml/src/vecdb/store.rsindex 29bd0de331..1c0cc61c06 100644--- a/rust/crates/ml/src/vecdb/store.rs+++ b/rust/crates/ml/src/vecdb/store.rs@@ -6,7 +6,7 @@ use std::time::{Duration, Instant};use super::arena::{UpsertOutcome, VECTORS_PER_CHUNK, VectorArena};use super::graph::{Graph, search as graph_search};-use super::lock::lock_exclusive;+use super::lock::{WriterLock, lock_path};use super::log::{HEADER_LEN, Log, LogEntry, LogRecord, remove_if_present, remove_stale_temp_sibling,sync_parent_dir,@@ -50,6 +50,7 @@ enum Mode {}struct WriterState {+ lock: WriterLock,log: Log,mutations_since_snapshot: usize,last_write: Option<Instant>,@@ -57,18 +58,14 @@ struct WriterState {impl VecDb {pub fn open(path: &Path, dims: usize) -> Result<Self, VecDbError> {- let file = match Log::create(path, dims) {- Ok(created) => created.into_file(),+ let lock = WriterLock::acquire(path)?;+ let mut log = match Log::create(path, dims) {+ Ok(created) => created,Err(VecDbError::Io { source, .. }) if source.kind() == ErrorKind::AlreadyExists => {- File::options()- .read(true)- .write(true)- .open(path)- .map_err(|source| VecDbError::io(path, source))?+ reopen_log(path, dims)?}Err(error) => return Err(error),};- let mut log = open_locked(file, path, dims)?;remove_stale_temp_sibling(path)?;let snapshot_present = std::fs::metadata(snapshot_path(path)).is_ok();let replayed = replay(&mut log, dims)?;@@ -92,6 +89,7 @@ impl VecDb {total_records: replayed.total_records,compaction_retry_at_dead: 0,mode: Mode::Writer(WriterState {+ lock,log,mutations_since_snapshot: 0,last_write: None,@@ -265,17 +263,15 @@ impl VecDb {}pub fn reset(&mut self) -> Result<(), VecDbError> {- let old_state = self.take_writer_state()?;- let old_generation = old_state.log.generation();- drop(old_state);+ let WriterState { lock, log, .. } = self.take_writer_state()?;+ let old_generation = log.generation();+ drop(log);let dims = self.arena.dims();- let recreated = remove_index_files(&self.path)- .and_then(|()| Log::create(&self.path, dims))- .and_then(|created| open_locked(created.into_file(), &self.path, dims));+ let recreated = remove_data_files(&self.path).and_then(|()| Log::create(&self.path, dims));let log = match recreated {Ok(log) => log,Err(error) => {- self.recover_after_failed_reset(dims, old_generation);+ self.recover_after_failed_reset(lock, dims, old_generation);return Err(error);}};@@ -284,6 +280,7 @@ impl VecDb {self.total_records = 0;self.compaction_retry_at_dead = 0;self.mode = Mode::Writer(WriterState {+ lock,log,mutations_since_snapshot: 0,last_write: None,@@ -295,8 +292,11 @@ impl VecDb {let Mode::Writer(state) = self.mode else {return Err(VecDbError::ReadOnly);};- drop(state);- remove_index_files(&self.path)+ let WriterState { lock, log, .. } = state;+ drop(log);+ let removed = remove_index_files(&self.path);+ drop(lock);+ removed}pub fn stats(&self) -> Stats {@@ -350,12 +350,14 @@ impl VecDb {fn restore_writer_mode(&mut self,+ lock: WriterLock,dims: usize,last_write: Option<Instant>,) -> Result<(), VecDbError> {- match open_path_locked(&self.path, dims) {+ match reopen_log(&self.path, dims) {Ok(log) => {self.mode = Mode::Writer(WriterState {+ lock,log,mutations_since_snapshot: 0,last_write,@@ -376,8 +378,13 @@ impl VecDb {}}- fn recover_after_failed_reset(&mut self, dims: usize, old_generation: [u8; 16]) {- let old_log_restored = self.restore_writer_mode(dims, None).is_ok()+ fn recover_after_failed_reset(+ &mut self,+ lock: WriterLock,+ dims: usize,+ old_generation: [u8; 16],+ ) {+ let old_log_restored = self.restore_writer_mode(lock, dims, None).is_ok()&& matches!(&self.mode, Mode::Writer(state) if state.log.generation() == old_generation);if old_log_restored {return;@@ -457,7 +464,13 @@ impl VecDb {return Err(VecDbError::io(&temp_path, source));}drop(temp_file);- let last_write = self.take_writer_state()?.last_write;+ let WriterState {+ lock,+ log,+ last_write,+ ..+ } = self.take_writer_state()?;+ drop(log);let promoted = promote_compacted_log(&temp_path, &self.path);if temp_path.exists() {let _ = std::fs::remove_file(&temp_path);@@ -466,7 +479,7 @@ impl VecDb {self.graph = Graph::rebuild(&self.arena);self.total_records = self.arena.live_count() as u64;}- let restored = self.restore_writer_mode(dims, last_write);+ let restored = self.restore_writer_mode(lock, dims, last_write);promoted?;restored?;self.write_snapshot_now()@@ -591,18 +604,13 @@ fn ensure_finite(key: &str, vector: &[f32]) -> Result<(), VecDbError> {Ok(())}-fn open_locked(file: File, path: &Path, dims: usize) -> Result<Log, VecDbError> {- lock_exclusive(&file, path)?;- Log::open(file, path, dims)-}--fn open_path_locked(path: &Path, dims: usize) -> Result<Log, VecDbError> {+fn reopen_log(path: &Path, dims: usize) -> Result<Log, VecDbError> {let file = File::options().read(true).write(true).open(path).map_err(|source| VecDbError::io(path, source))?;- open_locked(file, path, dims)+ Log::open(file, path, dims)}fn promote_compacted_log(temp_path: &Path, path: &Path) -> Result<(), VecDbError> {@@ -611,6 +619,11 @@ fn promote_compacted_log(temp_path: &Path, path: &Path) -> Result<(), VecDbError}fn remove_index_files(path: &Path) -> Result<(), VecDbError> {+ remove_data_files(path)?;+ remove_if_present(&lock_path(path))+}++fn remove_data_files(path: &Path) -> Result<(), VecDbError> {remove_if_present(path)?;remove_snapshot(path)?;remove_stale_temp_sibling(path)@@ -1081,6 +1094,46 @@ mod tests {assert_eq!(reopened.len(), 3);}+ #[test]+ fn writer_stays_locked_across_a_completed_compaction() {+ let dir = TempDir::new().unwrap();+ let path = dir.path().join("db");+ let mut db = open_writer(&path);+ db.bulk_add(&bulk_entries(0, 120, 340)).unwrap();+ let generation_before = generation_of(&path);+ let removals: Vec<String> = (0..64).map(|index| format!("key-{index}")).collect();+ assert_eq!(db.bulk_remove(&removals).unwrap(), 64);+ assert_ne!(generation_of(&path), generation_before);+ assert_eq!(db.stats().dead_count, 0);+ let Err(error) = VecDb::open(&path, DIMS) else {+ panic!("second writer must not open after compaction");+ };+ assert!(matches!(error, VecDbError::Locked(locked) if locked == path));+ db.add("post", &seeded_unit_vector(7, DIMS)).unwrap();+ drop(db);+ let reopened = open_writer(&path);+ assert_eq!(reopened.len(), 57);+ assert!(reopened.contains("post"));+ assert!(!reopened.contains("key-0"));+ }++ #[test]+ fn stale_lock_file_with_garbage_bytes_is_reused_at_open() {+ let dir = TempDir::new().unwrap();+ let path = dir.path().join("db");+ fs::write(lock_path(&path), [0xAB; 24]).unwrap();+ let mut db = open_writer(&path);+ db.add("fresh", &seeded_unit_vector(3, DIMS)).unwrap();+ let Err(error) = VecDb::open(&path, DIMS) else {+ panic!("second writer must not open");+ };+ assert!(matches!(error, VecDbError::Locked(locked) if locked == path));+ drop(db);+ let reopened = open_writer(&path);+ assert_eq!(reopened.len(), 1);+ assert!(reopened.contains("fresh"));+ }+#[test]fn read_only_opens_alongside_a_writer() {let dir = TempDir::new().unwrap();@@ -1121,6 +1174,7 @@ mod tests {);assert!(!path.exists());assert!(!snapshot_exists(&path));+ assert!(!lock_path(&path).exists());}#[test]@@ -1509,6 +1563,7 @@ mod tests {assert_eq!(db.stats().log_bytes, 0);assert_eq!(fs::read(&path).unwrap(), partial);assert!(!snapshot_exists(&path));+ assert!(!lock_path(&path).exists());}#[test]@@ -1524,7 +1579,7 @@ mod tests {assert!(!temp.exists());assert_eq!(generation_of(&path), new_generation);assert_ne!(generation_of(&path), old_generation);- let log = open_path_locked(&path, DIMS).unwrap();+ let log = reopen_log(&path, DIMS).unwrap();assert_eq!(log.generation(), new_generation);drop(log);assert!(matches!(@@ -1535,14 +1590,19 @@ mod tests {}#[test]- fn restore_writer_mode_relocks_and_reenables_writes() {+ fn restore_writer_mode_reinstalls_the_kept_lock_and_reenables_writes() {let dir = TempDir::new().unwrap();let path = dir.path().join("db");let mut db = open_writer(&path);db.bulk_add(&bulk_entries(0, 3, 260)).unwrap();- drop(db.take_writer_state().unwrap());+ let WriterState { lock, log, .. } = db.take_writer_state().unwrap();+ drop(log);assert!(matches!(db.mode, Mode::ReadOnly { .. }));- db.restore_writer_mode(DIMS, None).unwrap();+ assert!(matches!(+ VecDb::open(&path, DIMS),+ Err(VecDbError::Locked(_))+ ));+ db.restore_writer_mode(lock, DIMS, None).unwrap();db.add("after", &seeded_unit_vector(4, DIMS)).unwrap();assert!(matches!(VecDb::open(&path, DIMS),@@ -1561,12 +1621,13 @@ mod tests {let path = dir.path().join("db");let mut db = open_writer(&path);db.bulk_add(&bulk_entries(0, 3, 270)).unwrap();- drop(db.take_writer_state().unwrap());+ let WriterState { lock, log, .. } = db.take_writer_state().unwrap();+ drop(log);let mut bytes = fs::read(&path).unwrap();bytes[20] ^= 0x5A;fs::write(&path, &bytes).unwrap();assert!(matches!(- db.restore_writer_mode(DIMS, None),+ db.restore_writer_mode(lock, DIMS, None),Err(VecDbError::Corrupt(_))));assert!(matches!(db.mode, Mode::ReadOnly { log_bytes } if log_bytes == bytes.len() as u64));@@ -1731,10 +1792,11 @@ mod tests {let mut db = open_writer(&path);db.bulk_add(&bulk_entries(0, 5, 330)).unwrap();let old_generation = generation_of(&path);- drop(db.take_writer_state().unwrap());- remove_index_files(&path).unwrap();+ let WriterState { lock, log, .. } = db.take_writer_state().unwrap();+ drop(log);+ remove_data_files(&path).unwrap();drop(Log::create(&path, DIMS).unwrap().into_file());- db.recover_after_failed_reset(DIMS, old_generation);+ db.recover_after_failed_reset(lock, DIMS, old_generation);assert!(db.is_empty());assert!(!db.contains("key-0"));assert_eq!(db.stats().log_bytes, 32);@@ -1757,10 +1819,12 @@ mod tests {fs::write(temp_sibling(&path), [7u8; 10]).unwrap();assert!(path.exists());assert!(snapshot_exists(&path));+ assert!(lock_path(&path).exists());db.delete().unwrap();assert!(!path.exists());assert!(!snapshot_exists(&path));assert!(!temp_sibling(&path).exists());+ assert!(!lock_path(&path).exists());}#[test]