Under MVCC, implicit rowid allocation behaves like a sequence: the next
value comes from a high-water mark that a rollback does not lower, so an
aborted insert consumes its rowid for good and the next insert skips
past it. This is deliberate — we do not guarantee that a rolled-back
allocation is handed back, matching PostgreSQL sequences, where nextval
is never rolled back and aborted transactions leave permanent gaps.
(AUTOINCREMENT already behaved this way; the same rule now covers plain
INTEGER PRIMARY KEY rowids.) WAL mode, like SQLite, reuses the freed
value.
The simulator makes exact-row assertions, and it cannot predict a
post-rollback rowid without modeling that watermark. Rather than model
it, generate explicit integer primary keys in MVCC INSERT and UPSERT
workloads, so the assertions no longer assume rolled-back allocations
come back. WAL mode keeps generating implicit keys.
Check MVCC integrity with Turso, which can read the logical-log state
SQLite cannot, and keep the SQLite integrity check for WAL. Export the
logical log from the in-memory I/O so a retained failure artifact
includes committed state.
Tests: 21 generator tests, the MVCC profile regression, and
deterministic integrity and export regressions pass.
Keep completed file mutations separate from the bytes protected by a
successful sync so power loss can discard unsynced writes and truncations.
Cancel pending I/O at the crash boundary, invalidate old file handles,
and retain mutation completion order when updating durable bytes.
The previous approach (34db5d989) tried to detect stale DATABASE_MANAGER
entries by storing the inode at open time and comparing it on lookup.
This required a zero sentinel for unknown inodes, platform cfg gates
everywhere, and silently assumed a match when identity couldn't be
determined — all of which papered over the real problem: path strings
are the wrong key for a file registry.
Like SQLite's inodeList, the process-wide database registry is now keyed
by (device, inode) instead of canonical path strings. This makes stale
entry detection impossible by construction: a deleted-and-recreated file
has a different inode, so it naturally gets a fresh registry entry.
MemorySimIO read handling assumed the requested range always existed in the
in-memory file buffer and indexed directly into slices. Under fault-heavy runs,
that produced out-of-bounds panics instead of an I/O-style result.
This change gives MemorySimIO pread behavior that matches real file I/O:
- read past EOF returns 0 bytes
- partial range returns the available prefix
- unread tail bytes in the destination buffer are zero-filled for deterministic tests
Short-read detection remains the caller's job via completion callbacks, which is
how the real IO stack reports short reads today.
Add full infrastructure for testing ATTACH databases in the simulator:
- SimulatorEnv tracks attached databases with path helpers and cleanup
- Selective per-file fault injection via inject_fault_selective() on SimIO
- CREATE TABLE redirect to attached DBs (30% probability) in plan generation
- Proper QualifiedName/DoublyQualified handling for dotted table names in
sql_generation (FROM clauses, column references, result columns)
- Re-ATTACH on database reopen with DatabaseOpts::with_attach(true)
- Fix core/connection.rs attach_database() to reuse parent DB IO instead
of creating a new PlatformIO (enables simulator fault injection)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>