mirror of
https://github.com/pirate/ArchiveBox.git
synced 2025-08-24 07:03:03 +02:00
add max 5s writing delay for concurrent writers and flush WAL slower
This commit is contained in:
@@ -1169,10 +1169,17 @@ def setup_django(out_dir: Path=None, check_db=False, config: ConfigDict=CONFIG,
|
|||||||
# Enable WAL mode in sqlite3
|
# Enable WAL mode in sqlite3
|
||||||
from django.db import connection
|
from django.db import connection
|
||||||
with connection.cursor() as cursor:
|
with connection.cursor() as cursor:
|
||||||
|
|
||||||
|
# Set Journal mode to WAL to allow for multiple writers
|
||||||
current_mode = cursor.execute("PRAGMA journal_mode")
|
current_mode = cursor.execute("PRAGMA journal_mode")
|
||||||
if current_mode != 'wal':
|
if current_mode != 'wal':
|
||||||
cursor.execute("PRAGMA journal_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
|
# Create cache table in DB if needed
|
||||||
try:
|
try:
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
|
Reference in New Issue
Block a user