Skip to content

build(deps): Bump postgres 18 - #4538

Merged
aldy505 merged 2 commits into
getsentry:masterfrom
aminvakil:postgres_18
Oct 6, 2026
Merged

aldy505 merged 2 commits into
getsentry:masterfrom
aminvakil:postgres_18

Conversation

@aminvakil

Copy link
Copy Markdown
Collaborator

Follow up to #4504.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit dc9b008. Configure here.

Comment thread install/upgrade-postgres.sh
@aminvakil
aminvakil marked this pull request as ready for review September 30, 2026 21:29
@aminvakil
aminvakil force-pushed the postgres_18 branch 2 times, most recently from 76fc105 to 924b369 Compare October 4, 2026 09:22
@aminvakil

Copy link
Copy Markdown
Collaborator Author

This has been tested locally with different bases (pg14-bookworm, pg14-trixie) and it works fine.

@aminvakil
aminvakil requested review from BYK and aldy505 October 5, 2026 08:50

@aldy505 aldy505 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already very good to me, but there is one thing to address.

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."

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we put the big warning sign here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The 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 ./install.sh or that does not break.

This is unrelated to reindex issues which users reported on different issues.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a nitpick, to avoid any user complains that they didn't read the error message.

Comment on lines +54 to +62
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"
'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice.

Comment on lines +68 to +80
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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'd need a third step, from @kostirez1 on Discord:

FYI: POSTGRES_INITDB_ARGS=--no-data-checksums

Starting with PG18 (26.10.0+), new Sentry installs will have data checksums enabled, because that's now the PostgreSQL default. Existing clusters (PG14) will keep running without them.

It's a minor point, but the next major upgrade (PG18 -> 19) has to account for this setting. pg_upgrade fails if the old and new clusters have different checksum settings.

To fix this, enable checksums with pg_checksums --enable right after the upgrade, before PG18 takes traffic. It needs the cluster offline and rewrites every data file, so it fits best inside the upgrade's downtime window.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Continuation and summary of my messages on Discord:

Enabling pg_checksums is something unrelated to this PR, we can decide whether to activate that or not, as that would need a complete read of all databases / tables / indexes, it could happen in another release or this release but another PR, either way I intend to keep this PR just for upgrading from 14 to 18.

Let's decide whether to enable pg_checksums or keep it disabled later.

@aldy505
aldy505 merged commit 95c2f68 into getsentry:master Oct 6, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants