SQLite Forum

A testcase causing Assertion `p->journalMode!=PAGER_JOURNALMODE_OFF || !isOpen(p->jfd)' failed
Login

A testcase causing Assertion `p->journalMode!=PAGER_JOURNALMODE_OFF || !isOpen(p->jfd)' failed

(1) By Jingzhou Fu (fuboat) on 2022-01-02 18:06:29 [link] [source]

System Information:

compile-time options: CC=clang-12 ./configure --enable-debug
sqlite3_sourceid: 2022-01-02 16:48:00 fef72368a2eef5cb68ffc56e4f01be212d5e3318ebdb56a23ab26e1ef454272e
output: sqlite3.c:53640: assert_pager_state: Assertion `p->journalMode!=PAGER_JOURNALMODE_OFF || !isOpen(p->jfd)' failed.

PoC (test.db does not exist before running the following script):

.open
ATTACH 'test.db' AS vacuum_db;
PRAGMA journal_mode = wal;
PRAGMA journal_mode = persist;
.open
ATTACH 'test.db' AS vacuum_db;
PRAGMA journal_mode=OFF;
PRAGMA journal_mode = wal;
.open
ATTACH 'test.db' AS vacuum_db;
PRAGMA journal_mode=OFF;

(2) By Richard Hipp (drh) on 2022-01-02 18:20:49 in reply to 1 [link] [source]

Simplified test case:

.open --new test.db
PRAGMA journal_mode=WAL;
PRAGMA journal_mode=PERSIST;
.open test.db
PRAGMA journal_mode=OFF;
PRAGMA journal_mode=WAL;
.open test.db
PRAGMA journal_mode=OFF;

(3) By RandomCoder on 2022-01-02 19:07:07 in reply to 1 [link] [source]

Introduced in 3.15.1

(4) By RandomCoder on 2022-01-02 19:28:54 in reply to 3 [source]

Nope, I'm wrong. When run with Richard's version of the repro, it first shows up in 3.15.0 (typo on my part), when run with Jingzhou's original report, it first shows up 3 years earlier with 3.8.2

(5) By Richard Hipp (drh) on 2022-01-02 19:35:30 in reply to 1 [link] [source]

Fixed on trunk.

I was not able to discover any harm that could come of this (other than the obvious assertion fault when compiled in SQLITE_DEBUG mode). It is good to fix it, so that the internal state description is as simple as it can be, and consistent with the documentation and comments. But other than that, I can't find anything here that would impact a production application.

Did I miss something?