mirror of
https://github.com/allankoechke/turso.git
synced 2026-11-29 09:33:48 +00:00
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.