Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postgres cleanup script fails #3007

Open
csvan opened this issue Apr 30, 2024 · 3 comments
Open

Postgres cleanup script fails #3007

csvan opened this issue Apr 30, 2024 · 3 comments

Comments

@csvan
Copy link

csvan commented Apr 30, 2024

Self-Hosted Version

24.4.1

CPU Architecture

x86_64

Docker Version

24.0.7

Docker Compose Version

2.24.0

Steps to Reproduce

Run the postgres cleanup script from https://develop.sentry.dev/self-hosted/troubleshooting/#postgres :

# Only keep the last 7 days of nodestore data. We heavily use performance monitoring.
docker compose run --rm -T web cleanup --days 7 -m nodestore -l debug
# This ensures pg-repack exists before running as the container gets recreated on upgrades
docker compose run --rm -T postgres bash -c "apt update && apt install -y --no-install-recommends postgresql-14-repack && su postgres -c 'pg_repack -E info -t nodestore_node'"

Expected Result

It should clean out the database and return 0

Actual Result

It fails with the following:

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Get:1 http://deb.debian.org/debian bullseye InRelease [116 kB]
Get:2 http://apt.postgresql.org/pub/repos/apt bullseye-pgdg InRelease [123 kB]
Get:3 http://deb.debian.org/debian-security bullseye-security InRelease [48.4 kB]
Get:4 http://deb.debian.org/debian bullseye-updates InRelease [44.1 kB]
Get:5 http://deb.debian.org/debian bullseye/main amd64 Packages [8,068 kB]
Get:6 http://apt.postgresql.org/pub/repos/apt bullseye-pgdg/main amd64 Packages [314 kB]
Get:7 http://apt.postgresql.org/pub/repos/apt bullseye-pgdg/14 amd64 Packages [2,582 B]
Get:8 http://deb.debian.org/debian-security bullseye-security/main amd64 Packages [271 kB]
Get:9 http://deb.debian.org/debian bullseye-updates/main amd64 Packages [18.8 kB]
Fetched 9,005 kB in 2s (4,490 kB/s)
Reading package lists...
Building dependency tree...
Reading state information...
44 packages can be upgraded. Run 'apt list --upgradable' to see them.

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
The following NEW packages will be installed:
  postgresql-14-repack
0 upgraded, 1 newly installed, 0 to remove and 44 not upgraded.
Need to get 107 kB of archives.
After this operation, 255 kB of additional disk space will be used.
Get:1 http://apt.postgresql.org/pub/repos/apt bullseye-pgdg/main amd64 postgresql-14-repack amd64 1.5.0-1.pgdg110+1 [107 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 107 kB in 0s (382 kB/s)
Selecting previously unselected package postgresql-14-repack.
(Reading database ... 12113 files and directories currently installed.)
Preparing to unpack .../postgresql-14-repack_1.5.0-1.pgdg110+1_amd64.deb ...
Unpacking postgresql-14-repack (1.5.0-1.pgdg110+1) ...
Setting up postgresql-14-repack (1.5.0-1.pgdg110+1) ...
update-alternatives: using /usr/lib/postgresql/14/bin/pg_repack to provide /usr/bin/pg_repack (pg_repack) in auto mode
Processing triggers for postgresql-common (244.pgdg110+1) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Removing obsolete dictionary files:
ERROR: could not connect to database: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
	Is the server running locally and accepting connections on that socket?

Event ID

No response

@hubertdeng123
Copy link
Member

I believe this is happening since the su postgres -c... part of the command in the docs is not able to properly connect to postgres. Is your postgres instance otherwise healthy? Can you try to bring down your postgres container before running the command?

@csvan
Copy link
Author

csvan commented May 4, 2024

Apologies for the late reply @hubertdeng123 . Yes, the image is otherwise working fine (we are using vanilla on-prem so we are just using the defaul postgres image provided by Sentry). I tried stopping Sentry before running the cleanup, but the error is unfortunately still the same.

@azaslavsky
Copy link
Contributor

Can you run through this script to troubleshoot? I'm curious where things are breaking down - is psql not seeing the socket, does not exist, or something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Waiting for: Community
Status: Waiting for: Community
Status: No status
Development

No branches or pull requests

3 participants