From aa983f3082643c26fe57220d4f0b88b4fadc8141 Mon Sep 17 00:00:00 2001 From: Chris Amico Date: Wed, 4 Nov 2026 11:25:16 -0500 Subject: [PATCH] Add postgres statement timeout and 25 second limit in Procfile --- Procfile | 4 ++-- config/settings/production.py | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Procfile b/Procfile index 6ad49a94..9fa9de7c 100644 --- a/Procfile +++ b/Procfile @@ -1,5 +1,5 @@ release: ./postdeploy.sh -web: bin/start-nginx gunicorn -c config/gunicorn.conf config.wsgi:application +web: DB_STATEMENT_TIMEOUT=25000 bin/start-nginx gunicorn -c config/gunicorn.conf config.wsgi:application worker: REMAP_SIGTERM=SIGQUIT celery --app=config.celery_app worker --loglevel=info solr_worker: REMAP_SIGTERM=SIGQUIT celery --app=config.celery_app worker --loglevel=info -Q solr,celery -beat: REMAP_SIGTERM=SIGQUIT celery --app=config.celery_app beat --loglevel=info \ No newline at end of file +beat: REMAP_SIGTERM=SIGQUIT celery --app=config.celery_app beat --loglevel=info diff --git a/config/settings/production.py b/config/settings/production.py index cada5e59..490056f5 100644 --- a/config/settings/production.py +++ b/config/settings/production.py @@ -25,6 +25,12 @@ DATABASES["default"]["ATOMIC_REQUESTS"] = True # noqa F405 DATABASES["default"]["CONN_MAX_AGE"] = env.int("CONN_MAX_AGE", default=60) # noqa F405 +# Only the web dyno sets this; workers and migrations need to run long. +if statement_timeout := env.int("DB_STATEMENT_TIMEOUT", default=0): + DATABASES["default"]["OPTIONS"] = { # noqa F405 + "options": f"-c statement_timeout={statement_timeout}" + } + # SECURITY # ------------------------------------------------------------------------------ # https://docs.djangoproject.com/en/dev/ref/settings/#secure-proxy-ssl-header