Commit 01b0e1fa authored by Jonathan Piaget's avatar Jonathan Piaget
Browse files

Add idle-in-transaction timeout to prevent autovacuum blocking

parent 008e8132
Loading
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -20,6 +20,14 @@ ALLOWED_HOSTS = env.list("DJANGO_ALLOWED_HOSTS", default=["arclean.he-arc.ch"])
# DATABASES
# ------------------------------------------------------------------------------
DATABASES["default"]["CONN_MAX_AGE"] = env.int("CONN_MAX_AGE", default=60)  # noqa: F405
# Kill idle-in-transaction connections after 5 min to prevent autovacuum blocking.
# Without this, abandoned transactions (e.g. forgotten shell sessions) hold back vacuum,
# causing dead tuple buildup on hot tables like django_celery_beat_periodictasks.
# This led to a 2-day autovacuum lock on a single-page table, freezing pg_dump and celery beat.
# See: https://www.postgresql.org/docs/current/runtime-config-client.html#GUC-IDLE-IN-TRANSACTION-SESSION-TIMEOUT
DATABASES["default"]["OPTIONS"] = {  # noqa: F405
    "options": "-c idle_in_transaction_session_timeout=300000",  # 5 minutes (in ms)
}

# django-allauth
# ------------------------------------------------------------------------------