Skip to main content

lock_path_for

Function lock_path_for 

Source
pub fn lock_path_for(main: &Path) -> PathBuf
Expand description

Construct the cross-process lock sidecar path for a given main-file path. We append -lock to the file name (mirroring the <db>-wal sidecar convention); the lock file lives next to the main DB and is the byte-range target for WRITER_LOCK / READER_LOCK_RANGE (see platform::lock).

Issue #1: keeping the lock byte in a dedicated file prevents pager I/O on the main DB from ever overlapping the locked byte range. This matters on Windows because LockFileEx produces mandatory locks; once the main DB grew past the old past-EOF anchor at 0x4000_0000, page writes that crossed that byte failed with ERROR_LOCK_VIOLATION. With the sidecar, the lock handle and the pager handle target different files, so the failure mode cannot recur.