Fix ptrmap data corruption with pre-initialize autovacuum database#3894
Fix ptrmap data corruption with pre-initialize autovacuum database#3894ddwalias wants to merge 5 commits into
Conversation
|
The cause seem to be when Turso allocates leaf or overflow pages, it never writes the corresponding pointer‑map entries. I attempted to fix this issue with this commit, but seems like I introduced a new bug in the process. For this PR, I will focus only on updating the simulator. The fix will be on another PR. |
acc4edc to
8cc3476
Compare
ed4a35e to
036d820
Compare
036d820 to
20c75be
Compare
|
I managed to make the integration test passes, however, the simulator is still failing, likely from another issue |
29bd984 to
20c75be
Compare
|
This pull request has been marked as stale due to inactivity. It will be closed in 7 days if no further activity occurs. |
|
This pull request has been closed due to inactivity. Please feel free to reopen it if you have further updates. |
|
Similar to #3830 |
|
@ddwalias we've decided to award you the 800$ Turso Challenge reward, since you did patch the simulator to demonstrate However, after careful consideration, we chose to go a different route for fixing this bug. Here is our preferred
You're more than welcome to help us implement these fixes. As for the ptrmap fix in the b-tree, it's definitely something we want to implement, see the tracking |
|
/tip $800 @ddwalias |
|
Please visit Algora to complete your tip via Stripe. |
|
🎉🎈 @ddwalias has been awarded $800 by Turso Database! 🎈🎊 |
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