diff --git a/docker-compose.yml b/docker-compose.yml index 8873990cb3e..77a4a938e48 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -36,7 +36,7 @@ x-sentry-defaults: &sentry_defaults <<: *depends_on-healthy kafka: <<: *depends_on-healthy - postgres: + pgbouncer: <<: *depends_on-healthy memcached: <<: *depends_on-default @@ -144,6 +144,24 @@ services: POSTGRES_HOST_AUTH_METHOD: "trust" volumes: - "sentry-postgres:/var/lib/postgresql/data" + pgbouncer: + image: "edoburu/pgbouncer:v1.24.1-p1" + healthcheck: + <<: *healthcheck_defaults + # Using default user "postgres" from sentry/sentry.conf.example.py or value of POSTGRES_USER if provided + test: ["CMD-SHELL", "psql -U postgres -p 5432 -h 127.0.0.1 -tA -c \"select 1;\" -d postgres >/dev/null"] + depends_on: + postgres: + <<: *depends_on-healthy + environment: + DB_USER: ${POSTGRES_USER:-postgres} + DB_HOST: postgres + DB_NAME: postgres + AUTH_TYPE: trust + POOL_MODE: transaction + ADMIN_USERS: postgres,sentry + MAX_CLIENT_CONN: 10000 + kafka: <<: *restart_policy image: "confluentinc/cp-kafka:7.6.1" diff --git a/install/set-up-and-migrate-database.sh b/install/set-up-and-migrate-database.sh index 5ddf324c0b8..debebd2531d 100644 --- a/install/set-up-and-migrate-database.sh +++ b/install/set-up-and-migrate-database.sh @@ -3,6 +3,7 @@ echo "${_group}Setting up / migrating database ..." if [[ -z "${SKIP_SENTRY_MIGRATIONS:-}" ]]; then # Fixes https://github.com/getsentry/self-hosted/issues/2758, where a migration fails due to indexing issue start_service_and_wait_ready postgres + start_service_and_wait_ready pgbouncer os=$($dc exec postgres cat /etc/os-release | grep 'ID=debian') if [[ -z $os ]]; then diff --git a/sentry-admin.sh b/sentry-admin.sh index aeea2b36845..ef5608488f9 100755 --- a/sentry-admin.sh +++ b/sentry-admin.sh @@ -24,6 +24,7 @@ on the host filesystem. Commands that write files should write them to the '/sen # Actual invocation that runs the command in the container. invocation() { start_service_and_wait_ready postgres + start_service_and_wait_ready pgbouncer start_service_and_wait_ready redis --wait $dcr --no-deps -v "$VOLUME_MAPPING" -T -e SENTRY_LOG_LEVEL=CRITICAL web "$@" 2>&1 } diff --git a/sentry/sentry.conf.example.py b/sentry/sentry.conf.example.py index 826f43ae2d6..944dc6399b3 100644 --- a/sentry/sentry.conf.example.py +++ b/sentry/sentry.conf.example.py @@ -48,7 +48,7 @@ def get_internal_network(): "NAME": "postgres", "USER": "postgres", "PASSWORD": "", - "HOST": "postgres", + "HOST": "pgbouncer", "PORT": "", } }