A testcase causing Assertion `pPg || !MEMDB' failed
(1) By Jingzhou Fu (fuboat) on 2022-02-28 16:55:33 [source]
System Information:
compile-time options: CC=clang-12 ./configure --enable-debug
sqlite_source_id: 2022-02-28 13:38:28 f2f0426035d4e0334be000a3eb62bbd7d61fdab7c2ef9ba13cfdf6482396dd13
output: sqlite3: sqlite3.c:55590: int pager_playback_one_page(Pager *, i64 *, Bitvec *, int, int): Assertion `pPg || !MEMDB' failed.
PoC (HINT: the assertion appears when you exit sqlite3, for example, Ctrl+D, after running the following statements.):
pragma page_size=512;
pragma auto_vacuum=2;
CREATE TABLE t1(a);
INSERT INTO t1 VALUES(randomblob(5000));
COMMIT;
PRAGMA writable_tchema=ON;
PRAGMA auto_vacuum = full;
PRAGMA page_size = 1024;
PRAGMA auto_vacuum = 2;
PRAGMA integrity_check;
DELETE FROM t1 WHERE rowid%8;
PRAGMA integrity_check;
SAVEPOINT one;
PRAGMA incremental_vacuum = 100;
PRAGMA max_page_count = 2;
PRAGMA integrity_check;
DELETE FROM t1 WHERE rowid%8;
BEGIN;
PRAGMA incremental_vacuum = 100;
ROLLBACK;
CREATE TABLE sqlsim3(t1, a ,sqlsim2);
CREATE TABLE u ( c1 INTEGER NOT NULL ON CONFLICT ABORT UNIQUE ON CONFLICT IGNORE ) ;
BEGIN;
CREATE TRIGGER v BEFORE INSERT ON sqlsim3 BEGIN SELECT CASE
WHEN (new.a = 4) THEN RAISE(IGNORE) END;
END;
CREATE TABLE w(v1);
CREATE VIRTUAL TABLE v2 USING fts4 ( v3 );
(2) By Richard Hipp (drh) on 2022-03-01 14:45:56 in reply to 1 [link] [source]
Fixed by check-in 12c012162ce110a7.
This assertion fault appears to be completely harmless. In other words, the asserted condition does not seem to be necessarily true. So there is no reason to back-port this change or do a patch release.
The origin of the problem seems to be this:
- PRAGMA auto_vacuum=FULL;
- ... construct content in a database.
- BEGIN;
- ... delete some content
- PRAGMA incremental_vacuum=100000; -- Free up space in the file
- PRAGMA max_page_count=2; -- max_page_count set to current file size
- ROLLBACK; -- causes the file to grow in size
The ROLLBACK in the last step causes the actual file size (the page_count) to become larger than the max_page_count. That is harmless, as far as I can tell, but it seems like a goofy condition, so the change in check-in 12c012162ce110a7 was to cause the max_page_count to increase to be at least as big as the actual file size following a ROLLBACK.