heartwood every commit a ring

Drop SQLite mmap and reduce gunicorn to one worker

dca43280 by Isaac Bythewood · 15 days ago

Drop SQLite mmap and reduce gunicorn to one worker

Three processes (scheduler + two gunicorn workers) writing to the same
SQLite file with PRAGMA mmap_size=128MB hit a multi-process mmap hazard
that amplified into 'database disk image is malformed' on 2026-04-19.
Removing mmap eliminates the amplifier; one gunicorn worker further
reduces concurrent writers without affecting capacity for this site.
modified entrypoint.py
@@ -11,7 +11,7 @@ procs = [            "gunicorn",            "status.asgi:application",            "--workers",            "2",            "1",            "--max-requests",            "256",            "--timeout",
modified status/settings/__init__.py
@@ -113,12 +113,16 @@ DATABASES = {            # fail, which previously stranded alert state mid-transition.            'timeout': 30,            'transaction_mode': 'IMMEDIATE',            # mmap_size is intentionally omitted: gunicorn workers and the            # scheduler each open their own connection, and SQLite's mmap is            # documented as unsafe for multi-process writers — it amplified            # an unrelated WAL inconsistency into full database corruption            # on 2026-04-19.            'init_command': (                'PRAGMA journal_mode=WAL;'                'PRAGMA synchronous=NORMAL;'                'PRAGMA foreign_keys=ON;'                'PRAGMA temp_store=MEMORY;'                'PRAGMA mmap_size=134217728;'                'PRAGMA journal_size_limit=67108864;'                'PRAGMA cache_size=-20000;'            ),