self-hosted icon indicating copy to clipboard operation
self-hosted copied to clipboard

Unable to install pg_repack due to Postgres apt repo dropping Stretch support

Open Omeryl opened this issue 2 years ago • 10 comments

Self-Hosted Version

23.2.0.dev0

CPU Architecture

x86_64

Docker Version

20.10.12

Docker Compose Version

1.29.2

Steps to Reproduce

  1. docker-compose run -T postgres bash -c "apt update && apt install -y --no-install-recommends postgresql-9.6-repack && su postgres -c 'pg_repack -E info -t nodestore_node'"

Expected Result

pg_repack should install, and eventually be run.

Actual Result

Creating sentry_onpremise_postgres_run ... done
Setting up Change Data Capture

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

Ign:1 http://deb.debian.org/debian stretch InRelease
Get:2 http://security.debian.org/debian-security stretch/updates InRelease [59.1 kB]
Get:3 http://deb.debian.org/debian stretch-updates InRelease [93.6 kB]
Get:4 http://deb.debian.org/debian stretch Release [118 kB]
Get:5 http://deb.debian.org/debian stretch Release.gpg [3,177 B]
Get:6 http://security.debian.org/debian-security stretch/updates/main amd64 Packages [782 kB]
Ign:7 http://apt.postgresql.org/pub/repos/apt stretch-pgdg InRelease
Get:8 http://deb.debian.org/debian stretch/main amd64 Packages [7,080 kB]
Err:9 http://apt.postgresql.org/pub/repos/apt stretch-pgdg Release
  404  Not Found [IP: 87.238.57.227 80]
Reading package lists...
E: The repository 'http://apt.postgresql.org/pub/repos/apt stretch-pgdg Release' does not have a Release file.
ERROR: 100

Event ID

No response

Omeryl avatar Jan 31 '23 11:01 Omeryl

Looks like the 9.6 tag is used, which was based on stretch. They dropped stretch on Nov 7, 2022:

2022-11-07: Debian stretch (9) has been removed: https://www.postgresql.org/message-id/Y2kmqL%2BpCuSZiQBV%40msg.df7cb.de

Omeryl avatar Jan 31 '23 11:01 Omeryl

So, it looks like the workaround is to just replace the apt repo with the archive while trying to repack. They appear to have built 9.6 on Bullseye too, but that's a step I don't have time to try. https://hub.docker.com/layers/library/postgres/9.6.24-bullseye/images/sha256-b46fe71e80ab8572c206b0645d6965547940d14de021b282fb1076c4d87e4aac?context=explore

Omeryl avatar Jan 31 '23 11:01 Omeryl

Hmmm, thanks for ringing this up. We have plans on upgrading postgres to 14 which should fix this but putting on the backlog for now

hubertdeng123 avatar Feb 01 '23 18:02 hubertdeng123

Issue "Bump default Postgres from 9.6 to 14": https://github.com/getsentry/self-hosted/issues/1610

patsevanton avatar Feb 15 '23 06:02 patsevanton

@Omeryl what command did you use?

meotimdihia avatar Feb 19 '23 02:02 meotimdihia

I used this command:

sudo docker-compose run -T postgres bash -c "sed -i 's/http:\/\/apt.postgresql.or/https:\/\/apt-archive.postgresql.or/g' /etc/apt/sources.list.d/pgdg.list && cat /etc/apt/sources.list.d/pgdg.list && apt update|| true && apt install -y apt-transport-https ca-certificates && apt update && apt install -y --no-install-recommends postgresql-9.6-repack && su postgres -c 'pg_repack -E info -t nodestore_node'"

But got the error at the final command: su postgres -c 'pg_repack -E info -t nodestore_node' ( in the documentation)

psql: 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?

meotimdihia avatar Feb 19 '23 11:02 meotimdihia

Sounds like you don't have postgres running, is your sentry install up?

On Sun, Feb 19, 2023 at 6:40 AM Dien Vu @.***> wrote:

I used this command:

sudo docker-compose run -T postgres bash -c "sed -i 's/http://apt.postgresql.or/https://apt-archive.postgresql.or/g' /etc/apt/sources.list.d/pgdg.list && cat /etc/apt/sources.list.d/pgdg.list && apt update|| true && apt install -y apt-transport-https ca-certificates && apt update && apt install -y --no-install-recommends postgresql-9.6-repack && su postgres -c 'pg_repack -E info -t nodestore_node'"

But got the error at the final command: su postgres -c 'pg_repack -E info -t nodestore_node' ( in the documentation)

psql: 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?

— Reply to this email directly, view it on GitHub https://github.com/getsentry/self-hosted/issues/1946#issuecomment-1435965070, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSAWF6GSKIDGQ7NWWZL25DWYIBBRANCNFSM6AAAAAAUMJ7VVU . You are receiving this because you were mentioned.Message ID: @.***>

Omeryl avatar Feb 19 '23 15:02 Omeryl

@Omeryl yes, everything works fine. It looks like the container can't connect to Postgres container. Because I can run the command if I run directly in Postgres container. ....

meotimdihia avatar Feb 19 '23 16:02 meotimdihia

With the release of 23.4 which upgrades Postgres to v14. I assume the steps for repack will need to be updated? https://develop.sentry.dev/self-hosted/troubleshooting/#postgres

LorenDorez avatar Apr 18 '23 18:04 LorenDorez

try this,

login into the Postgres container

docker exec -it sentry-self-hosted-postgres-1 bash

Update the apt repo

rm /etc/apt/sources.list.d/pgdg.list
echo "deb https://apt-archive.postgresql.org/pub/repos/apt/ stretch-pgdg main" > /etc/apt/sources.list.d/pgdg.list
echo "deb http://archive.debian.org/debian stretch main" > /etc/apt/sources.list

apt-get update && apt-get install apt-file -y && apt-file update

apt-get install apt-transport-https

Install repack

apt install --no-install-recommends postgresql-9.6-repack

Create extension

docker-compose exec postgres bash -c "psql -U postgres -c 'CREATE EXTENSION pg_repack' -d postgres"

ctgdevops avatar Aug 22 '23 11:08 ctgdevops