diff --git a/CHANGES.rst b/CHANGES.rst index f3934db2..ef1dee0d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -11,6 +11,30 @@ Version 1.4 Unreleased +* Use SQLite's `write-ahead logging`_ by default, + to increase concurrency and prevent "database is locked" errors. + (:issue:`169`, :issue:`175`) + + This changes how the database appears on disk and how it can be used; + most importantly: + + * There are additional quasi-persistent ``-wal`` and ``-shm`` files + associated with the database. + Backing up the database by simply copying it may not be enough + (this was also true before this change, to a lesser extent). + To make a backup of the database, use the SQLite CLI:: + + sqlite3 src.sqlite ".backup 'dst.sqlite'" + + * All processes using the database must be on the same host computer; + WAL does not work over a network filesystem. + + *reader* will enable WAL exactly once: at creation for new databases, + and when migrating to reader 1.4 for existing databases. + After this, it can be disabled again from the SQLite CLI:: + + sqlite3 db.sqlite "pragma journal_mode = delete;" + * Do not fail for feeds with incorrectly-declared media types, if feedparser can parse the feed; this is similar to the current behavior for incorrectly-declared encodings. @@ -23,6 +47,9 @@ Unreleased * Other minor web application improvements. +.. _write-ahead logging: https://www.sqlite.org/wal.html + + Version 1.3 ----------- diff --git a/src/reader/_storage.py b/src/reader/_storage.py index 21b780a0..0e9d04d0 100644 --- a/src/reader/_storage.py +++ b/src/reader/_storage.py @@ -54,6 +54,9 @@ def create_db(db: sqlite3.Connection) -> None: create_feeds(db) create_entries(db) create_feed_metadata(db) + # https://github.com/lemon24/reader/issues/169 + # https://github.com/lemon24/reader/issues/175 + db.execute("PRAGMA journal_mode = WAL;") def create_feeds(db: sqlite3.Connection, name: str = 'feeds') -> None: @@ -142,16 +145,22 @@ def update_from_18_to_19(db: sqlite3.Connection) -> None: # pragma: no cover db.execute("ALTER TABLE feeds ADD COLUMN last_exception TEXT;") +def update_from_19_to_20(db: sqlite3.Connection) -> None: # pragma: no cover + # for https://github.com/lemon24/reader/issues/169 + db.execute("PRAGMA journal_mode = WAL;") + + def setup_db(db: sqlite3.Connection) -> None: return setup_sqlite_db( db, create=create_db, - version=19, + version=20, migrations={ # 1-9 removed before 0.1 (last in e4769d8ba77c61ec1fe2fbe99839e1826c17ace7) # 10-16 removed before 1.0 (last in 618f158ebc0034eefb724a55a84937d21c93c1a7) 17: update_from_17_to_18, 18: update_from_18_to_19, + 19: update_from_19_to_20, }, # Row value support was added in 3.15. minimum_sqlite_version=(3, 15),