-
-
Notifications
You must be signed in to change notification settings - Fork 227
fix: add checksum to upgrade scripts #2021
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: develop
Are you sure you want to change the base?
Conversation
WalkthroughThe PR modifies the PostgreSQL upgrade initialization script to detect data checksums on the old cluster and propagate the checksum setting to the new database initialization. Additionally, it updates three PostgreSQL release version strings for different variants. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
203501d to
2720eb4
Compare
|
Tested upgrade with various checksum/no checksum permutations, pause and restore and functionality. Ready for review and merge |
|
@jchancojr take a peek? |
jchancojr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm ty!
|
|
|
The Problem
Users upgrading via Supabase UI encounter this error:
old cluster uses data checksums but the new one does not
Root Cause
Commit cf9bce1 (Nov 14, 2025) enabled data checksums for new PostgreSQL
installations, but the pg_upgrade scripts were not updated to match.
Affected Files
File: ansible/tasks/setup-postgres.yml
Has --data-checksums?: Yes
Lines: https://github.com/supabase/postgres/blob/develop/ansible/tasks/setup-postgres.yml#L232,
https://github.com/supabase/postgres/blob/develop/ansible/tasks/setup-postgres.yml#L260,
https://github.com/supabase/postgres/blob/develop/ansible/tasks/setup-postgres.yml#L277
────────────────────────────────────────
File: ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh
Has --data-checksums?: No
Lines: https://github.com/supabase/postgres/blob/develop/ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh#L470,
https://github.com/supabase/postgres/blob/develop/ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh#L472,
https://github.com/supabase/postgres/blob/develop/ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh#L475
What Happens
The Fix
Detect whether the old cluster has checksums enabled using pg_controldata, then conditionally pass --data-checksums to initdb.
Add detection after PGDATAOLD is set (after line 244):
Check if old cluster has data checksums enabled
CHECKSUM_VERSION=$("$PGBINOLD/pg_controldata" "$PGDATAOLD" | grep -i checksum | awk '{print $NF}')
if [ "$CHECKSUM_VERSION" != "0" ]; then
CHECKSUM_FLAG="--data-checksums"
else
CHECKSUM_FLAG=""
fi
Update all three initdb calls to use $CHECKSUM_FLAG:
$PGBINNEW/initdb $CHECKSUM_FLAG --encoding=$SERVER_ENCODING --locale-provider=icu ...
$PGBINNEW/initdb $CHECKSUM_FLAG --encoding=$SERVER_ENCODING --lc-collate=...
$PGBINNEW/initdb $CHECKSUM_FLAG -L $PGSHARENEW -D $PGDATANEW/ --username=supabase_admin
Summary by CodeRabbit
New Features
Chores
✏️ Tip: You can customize this high-level summary in your review settings.