mirror of
https://github.com/allankoechke/turso.git
synced 2026-11-30 11:12:58 +00:00
In MVCC mode with `PRAGMA mvcc_checkpoint_threshold = 0`, releasing the
outer savepoint reported an error even though the transaction was
committed. An application that retried after the error wrote the rows
twice.
```sql
PRAGMA journal_mode='mvcc';
PRAGMA mvcc_checkpoint_threshold = 0;
CREATE TABLE a(id INTEGER PRIMARY KEY, v TEXT);
SAVEPOINT s1;
INSERT INTO a(v) VALUES ('x');
RELEASE s1; -- before: Transaction error: no such savepoint: s1
SELECT count(*) FROM a; -- 1
```
`RELEASE` removes the savepoint and then commits through
`op_auto_commit`. With threshold 0, that commit runs a checkpoint, which
waits on I/O. When the instruction runs again, `RELEASE` looked up the
savepoint from the start, but the savepoint was already removed, so it
returned `NotFound`.
Now, if a commit is already in progress when `RELEASE` runs, it goes
straight back to `op_auto_commit` to finish that commit.
`op_auto_commit` already handles resuming a commit this way.
Fixes #9748
Autofixer wrote this change with Claude Code in an isolated sandbox. A
separate verifier agent tested and reviewed it in its own container
before this PR was opened. A maintainer must review it before merge.
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>
Closes #9762