SQLite commit-error-arm coverage (task sqlite-commit-error-arm): the wave-3 review gate's deferred test landed — failed_commit_replenishes_the_writer_slot drives a failing COMMIT through the engine's commit path and pins the review's code-read fix end-to-end: the error surfaces as the opaque Database carrying the SQLITE_FULL-shaped source chain, the failed connection is dropped and the writer slot replenished via the handle's reopen closure (the next begin_tx proceeds within a bounded timeout, no parking — the store-wide-livelock posture), no partial-commit residue (the dropped connection's uncommitted writes read back None), the post-failure commit is a real clean commit (the fault disarms on consumption), and auto-commit notify works afterward. Injection is a cfg(test) commit-fault seam in seam.rs — a per-store Arc<AtomicBool> arm (born disarmed, armed via arm_commit_fault, take() disarms on first consumption so exactly one commit faults) whose fabricated rusqlite SqliteFailure feeds the production commit error arm rather than replicating it; the PRAGMA max_page_count route was probed live against both WAL and DELETE journal modes first and rejected: SQLite checks the page-count limit at page-allocation time, so the squeeze always fails the growth statement (SQLITE_FULL/DiskFull on the first INSERT) and leaves no transaction active for COMMIT to fail — the arm is unreachable through PRAGMA-space (also probed: the pragma is per-connection, so pre-begin arming on the writer conn would have ridden into the tx conn; the route failed on error placement, not delivery). Mechanism choice and probes documented in the seam doc comment and the task Notes. Cross-test safety is per-store scoping; parallel stores never see the arm. Replay-proofed live: with the error arm's writer_reopen replenish temporarily removed the test fails (begin_tx parks past the 5 s timeout — the stranding the review identified), reverted it passes. Plumbing follows the pg-fix-forwarder-reconnect cfg(test) precedent: fields on SqliteStore/SqliteTxHandle and a begin param are cfg-gated, production builds compile the plain path. The waves-1-2 review's optional watcher reconnect-success add rides here (taken — recorded in Notes): reconnect_success_resumes_wake_delivery drives run_poll_loop through its existing open_conn_fn seam (same instrument as the W-1 failure test), with the db file present throughout because the vanished-file route cannot reach the success body (file reappearance trips the dead-man's identity switch first): initial open + first two reconnects fail by injection, the third reconnect succeeds, and a subsequent commit wakes on_change — the success arm's data_version re-baseline and restored delivery pinned. Watcher shape untouched. Verified: cargo test -p alkstore-sqlite green server-less (191 lib + 25 suite), workspace cargo test 399/0, clippy -D warnings, fmt clean
This commit is contained in:
1 parent
36023914b2
commit
0c7744977c
6 files changed
+320
-8
No files matched your search
@@ -50,6 +50,12 @@ pub struct SqliteStore {
|
||||
watcher: Arc<SharedUpdateWatcher>,
|
||||
db_path: PathBuf,
|
||||
closed: Arc<AtomicBool>,
|
||||
/// The store's commit-fault arm (`sqlite-commit-error-arm`) — born
|
||||
/// disarmed; a test arms it through [`SqliteStore::arm_commit_fault`]
|
||||
/// so the next handle commit fails through the real commit error
|
||||
/// arm. Dead in production builds.
|
||||
#[cfg(test)]
|
||||
commit_fault: crate::seam::commit_fault::Flag,
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for SqliteStore {
|
||||
@@ -71,6 +77,16 @@ impl SqliteStore {
|
||||
self.readers.close();
|
||||
self.writer.close();
|
||||
}
|
||||
|
||||
/// Arm the commit-fault seam (`sqlite-commit-error-arm`): the
|
||||
/// next `commit` through a handle of this store fails with a
|
||||
/// `SQLITE_FULL`-shaped driver error and replenishes the writer
|
||||
/// slot through the real commit error arm. One-store scoping keeps
|
||||
/// parallel test stores unaffected.
|
||||
#[cfg(test)]
|
||||
pub(crate) fn arm_commit_fault(&self) {
|
||||
crate::seam::commit_fault::arm(&self.commit_fault)
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for SqliteStore {
|
||||
@@ -109,6 +125,8 @@ pub(crate) fn open_store(path: &str, opts: SqliteOpts) -> alkstore::Result<Sqlit
|
||||
watcher: Arc::new(watcher),
|
||||
db_path: PathBuf::from(path),
|
||||
closed: Arc::new(AtomicBool::new(false)),
|
||||
#[cfg(test)]
|
||||
commit_fault: crate::seam::commit_fault::disarmed(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -121,7 +139,11 @@ impl Store for SqliteStore {
|
||||
let reopen: std::sync::Arc<
|
||||
dyn Fn() -> alkstore::Result<rusqlite::Connection> + Send + Sync,
|
||||
> = std::sync::Arc::new(move || crate::seam::open_writer_connection(&db_path));
|
||||
crate::tx::SqliteTxHandle::begin(writer, reopen)
|
||||
#[cfg(test)]
|
||||
let fut = crate::tx::SqliteTxHandle::begin(writer, reopen, self.commit_fault.clone());
|
||||
#[cfg(not(test))]
|
||||
let fut = crate::tx::SqliteTxHandle::begin(writer, reopen);
|
||||
fut
|
||||
}
|
||||
|
||||
fn notify<'a>(
|
||||
|
||||
Reference in new issue
Block a user