Support for blocking VFS
(1) By David Matson (dmatson) on 2021-07-07 22:31:49 [link] [source]
We're using SQLite in a component with significant performance and parallelism requirements, and we would like to rely on OS locking rather than retry loops to handle multiple readers/writers. Stated another way, we'd like to find a way to ensure that we never see SQLITE_BUSY returned to the application and instead wait on an OS handle whenever such a condition would occur.
From looking at the source, it appears that the win32 VFS uses OS primitives that would support blocking rather than failing with SQLITE_BUSY when there is contention, but SQLite currently only uses these primitives in non-blocking mode. For example:
/* ** Currently, SQLite never calls the LockFileEx function without wanting the ** call to fail immediately if the lock cannot be obtained. */ #ifndef SQLITE_LOCKFILEEX_FLAGS # define SQLITE_LOCKFILEEX_FLAGS (LOCKFILE_FAIL_IMMEDIATELY) #endif
I was able to implementing something similar with a wrapper VFS for journal_mode = DELETE, by following the source for the current win32 VFS and replacing the non-blocking calls with blocking calls (I can share the code if that context would clarify things on this thread). However, for WAL mode, some calls to ShmLock appear to be "probes" that require the call to fail immediately if the lock isn't available, including cases with just one thread where the lock is guaranteed not to be available. For non-WAL mode, it looks like a correct implementation can block/wait to acquire the lock, but for WAL mode, the contract appears to prohibit waiting.
Two main questions: 1. For non-WAL-mode, how feasible would it be to support a blocking mode directly in SQLite? (rather than using a custom VFS, as seems possible today) 2. For WAL mode, would it be feasible to extend the VFS layer to make it possible to implement such a blocking version via a custom VFS?
(2) By anonymous on 2021-07-07 23:22:08 in reply to 1 [link] [source]
Did you see the blocking support for WAL mode databases?
(3.1) By David Matson (dmatson) on 2021-07-09 17:58:08 edited from 3.0 in reply to 2 [link] [source]
I had seen some related things in the source. It looks like that is POSIX-only - is that correct? I'm specifically looking for Windows support.
(4) By HowardKapustein (howardk) on 2021-12-07 04:58:55 in reply to 3.1 [link] [source]
Any news on this? It would be very useful for many scenarios
(5) By HowardKapustein (howardk) on 2022-01-06 06:55:10 in reply to 4 [source]
(6) By Richard Hipp (drh) on 2022-01-06 15:25:22 in reply to 5 [link] [source]
We are kinda overwhelmed dealing with other more pressing issues at the moment. Sorry for the delay.