From 2980c5884facebdede4f66171784f5e47e7ec969 Mon Sep 17 00:00:00 2001 From: Philipp Kolberg <39984529+PKizzle@users.noreply.github.com> Date: Fri, 14 Oct 2022 11:53:24 +0200 Subject: [PATCH] root: Add setting to adjust database config for pgbouncer (#3769) * Add setting to adjust database config for pgbouncer * docker-compose.yml cleanup Delete pgbouncer setting as false is the default value * Cleanup docker-compose.yml Also remove use_pgbouncer option in server section --- authentik/lib/default.yml | 1 + authentik/root/settings.py | 6 ++++++ website/docs/installation/configuration.md | 1 + 3 files changed, 8 insertions(+) diff --git a/authentik/lib/default.yml b/authentik/lib/default.yml index 5a2428cd6..44925bf5a 100644 --- a/authentik/lib/default.yml +++ b/authentik/lib/default.yml @@ -6,6 +6,7 @@ postgresql: user: authentik port: 5432 password: 'env://POSTGRES_PASSWORD' + use_pgbouncer: false listen: listen_http: 0.0.0.0:9000 diff --git a/authentik/root/settings.py b/authentik/root/settings.py index a91babefa..ee2a52c84 100644 --- a/authentik/root/settings.py +++ b/authentik/root/settings.py @@ -270,6 +270,12 @@ DATABASES = { } } +if CONFIG.y_bool("postgresql.use_pgbouncer", False): + # https://docs.djangoproject.com/en/4.0/ref/databases/#transaction-pooling-server-side-cursors + DATABASES["default"]["DISABLE_SERVER_SIDE_CURSORS"] = True + # https://docs.djangoproject.com/en/4.0/ref/databases/#persistent-connections + DATABASES["default"]["CONN_MAX_AGE"] = None # persistent + # Email EMAIL_HOST = CONFIG.y("email.host") EMAIL_PORT = int(CONFIG.y("email.port")) diff --git a/website/docs/installation/configuration.md b/website/docs/installation/configuration.md index ee3283574..b6876f9ff 100644 --- a/website/docs/installation/configuration.md +++ b/website/docs/installation/configuration.md @@ -32,6 +32,7 @@ kubectl exec -it deployment/authentik-worker -c authentik -- ak dump_config - `AUTHENTIK_POSTGRESQL__USER`: Database user - `AUTHENTIK_POSTGRESQL__PORT`: Database port, defaults to 5432 - `AUTHENTIK_POSTGRESQL__PASSWORD`: Database password, defaults to the environment variable `POSTGRES_PASSWORD` +- `AUTHENTIK_POSTGRESQL__USE_PGBOUNCER`: Adjust configuration to support connection to PgBouncer ## Redis Settings