Fix ptrmap data corruption with pre-initialize autovacuum database #3894
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reproduce:
sqlite3 /tmp/av_corruption.db "PRAGMA auto_vacuum=FULL; VACUUM; IF NOT EXISTS __sim_autovacuum_seed__(id INTEGER PRIMARY KEY, value TEXT); INSERT OR IGNORE INTO __sim_autovacuum_seed__ VALUES (1,'seed');"tursodb /tmp/av_corruption.db "CREATE TABLE t(a);" \ for i in $(seq 1 2000); do target/debug/tursodb /tmp/av_corruption.db "INSERT INTO t VALUES ($i);"; donePRAGMA integrity_check;-> it reportsTree … Failed to read ptrmap key=….. However, Turso’s ownPRAGMA integrity_check;still printsok, so the engine doesn’t notice the damage.Why the simulator misses it:
The deterministic runs always start from Turso-built databases, and never import a file produced by SQLite, so this path is never exercised.
Reference: #3895