-
-
Notifications
You must be signed in to change notification settings - Fork 2k
build(deps): Bump postgres 18 #4538
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| echo "${_group}Ensuring proper PostgreSQL version ..." | ||
|
|
||
| postgres_version=$($CONTAINER_ENGINE run --rm -v sentry-postgres:/db busybox sh -c 'if [ -f /db/PG_VERSION ]; then cat /db/PG_VERSION; fi') | ||
| postgres_version=$($CONTAINER_ENGINE run --rm -v sentry-postgres:/db busybox sh -c 'for data in /db /db/18/docker; do if [ -f "$data/PG_VERSION" ]; then cat "$data/PG_VERSION"; break; fi; done') | ||
|
|
||
| if [[ -n "$($CONTAINER_ENGINE volume ls -q --filter name=sentry-postgres)" && "$($CONTAINER_ENGINE run --rm -v sentry-postgres:/db busybox cat /db/PG_VERSION 2>/dev/null)" == "9.6" ]]; then | ||
| $CONTAINER_ENGINE volume rm sentry-postgres-new || true | ||
|
|
@@ -43,16 +43,43 @@ if [[ -n "$($CONTAINER_ENGINE volume ls -q --filter name=sentry-postgres)" && "$ | |
| $dc stop postgres | ||
| fi | ||
|
|
||
| # Reindex existing PostgreSQL 14 data once for the glibc 2.36 (Bookworm) -> 2.41 (Trixie) change. | ||
| if [[ "$postgres_version" == "14" || -z "$postgres_version" ]]; then | ||
| needs_reindex=$($CONTAINER_ENGINE run --rm -v sentry-postgres:/db busybox sh -c 'if [ -f /db/PG_VERSION ] && [ ! -f /db/14-trixie-reindexed ]; then echo yes; fi') | ||
| if $CONTAINER_ENGINE volume inspect sentry-postgres-new >/dev/null 2>&1; then | ||
| echo "Found sentry-postgres-new from an interrupted PostgreSQL upgrade. Recover the database before removing this volume and rerunning install.sh." | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we put the big warning sign here?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please explain what do you mean by "big warning sign"? This should not happen for normal users if they do not interrupt their This is unrelated to |
||
| exit 1 | ||
| fi | ||
|
|
||
| start_service_and_wait_ready postgres | ||
| if [[ "$needs_reindex" == "yes" ]]; then | ||
| echo "Re-indexing due to glibc change, this may take a while..." | ||
| $dc exec postgres psql -U postgres -v ON_ERROR_STOP=1 -c "REINDEX DATABASE postgres;" | ||
| if [[ "$postgres_version" == "14" ]]; then | ||
| # Reindex once under PostgreSQL 14 Trixie before upgrading the major version. | ||
| if ! $CONTAINER_ENGINE run --rm -v sentry-postgres:/db:ro busybox test -f /db/14-trixie-reindexed; then | ||
| echo "[1/2] PostgreSQL 14 Bookworm -> 14 Trixie: reindexing for the glibc change, this may take a while..." | ||
| $CONTAINER_ENGINE run --rm --user postgres --network none --shm-size=256m \ | ||
| -v sentry-postgres:/var/lib/postgresql/data \ | ||
| postgres:14.24-trixie bash -ec ' | ||
| trap "pg_ctl -m fast -w stop" EXIT | ||
| pg_ctl -w start | ||
| psql -U postgres -v ON_ERROR_STOP=1 -c "REINDEX DATABASE postgres;" | ||
| touch "$PGDATA/14-trixie-reindexed" | ||
| ' | ||
|
Comment on lines
+54
to
+62
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is nice. |
||
| echo "[1/2] PostgreSQL 14 Trixie reindex completed and database stopped." | ||
| else | ||
| echo "[1/2] PostgreSQL 14 Trixie reindex already completed; skipping." | ||
| fi | ||
| $dc exec postgres sh -c 'touch "$PGDATA/14-trixie-reindexed"' | ||
|
|
||
| echo "[2/2] PostgreSQL 14 Trixie -> 18 Trixie: upgrading..." | ||
| $CONTAINER_ENGINE run --rm \ | ||
| -e POSTGRES_INITDB_ARGS=--no-data-checksums \ | ||
| -v sentry-postgres:/var/lib/postgresql/14/data \ | ||
| -v sentry-postgres-new:/var/lib/postgresql/18/docker \ | ||
| tianon/postgres-upgrade:14-to-18 | ||
|
|
||
| echo "[2/2] pg_upgrade completed. Replacing the PostgreSQL 14 volume with PostgreSQL 18 data..." | ||
| $CONTAINER_ENGINE volume rm sentry-postgres | ||
| $CONTAINER_ENGINE volume create --name sentry-postgres | ||
| $CONTAINER_ENGINE run --rm -v sentry-postgres-new:/from -v sentry-postgres:/to alpine ash -ec \ | ||
| "mkdir -p /to/18/docker; cp -av /from/. /to/18/docker; echo 'host all all all trust' >> /to/18/docker/pg_hba.conf" | ||
| $CONTAINER_ENGINE volume rm sentry-postgres-new | ||
|
Comment on lines
+68
to
+80
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we'd need a third step, from @kostirez1 on Discord:
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Continuation and summary of my messages on Discord: Enabling Let's decide whether to enable |
||
| postgres_version=18 | ||
| echo "[2/2] PostgreSQL 18 Trixie upgrade completed." | ||
| fi | ||
|
|
||
| echo "${_endgroup}" | ||
Uh oh!
There was an error while loading. Please reload this page.