From 6e6686387168eb6358f5927e8a338876e03a8c4f Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Mon, 9 May 2022 18:36:27 -0700 Subject: [PATCH] add max 5s writing delay for concurrent writers and flush WAL slower --- archivebox/config.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/archivebox/config.py b/archivebox/config.py index 8abe7f00..21e48ff2 100644 --- a/archivebox/config.py +++ b/archivebox/config.py @@ -1169,10 +1169,17 @@ def setup_django(out_dir: Path=None, check_db=False, config: ConfigDict=CONFIG, # Enable WAL mode in sqlite3 from django.db import connection with connection.cursor() as cursor: + + # Set Journal mode to WAL to allow for multiple writers current_mode = cursor.execute("PRAGMA journal_mode") if current_mode != 'wal': cursor.execute("PRAGMA journal_mode=wal;") + # Set max blocking delay for concurrent writes and write sync mode + # https://litestream.io/tips/#busy-timeout + cursor.execute("PRAGMA busy_timeout = 5000;") + cursor.execute("PRAGMA synchronous = NORMAL;") + # Create cache table in DB if needed try: from django.core.cache import cache