Skip to content

feat: handle pg_net persistence mismatch for PG14 upgrade#2230

Open
cfunkhouser wants to merge 6 commits into
developfrom
cfunk/indata-757-handle-pg_net-persistence-mismatch-before-pg14-auto-upgrades
Open

feat: handle pg_net persistence mismatch for PG14 upgrade#2230
cfunkhouser wants to merge 6 commits into
developfrom
cfunk/indata-757-handle-pg_net-persistence-mismatch-before-pg14-auto-upgrades

Conversation

@cfunkhouser

Copy link
Copy Markdown

Execute ALTER TABLE net.http_request_queue SET LOGGED on PG14 databases before upgrade.

There is a state mismatch in which net.http_request_queue_id_seq sequence is logged, but the table net.http_request_queue is not. This mismatch prevents pg_upgrade from proceeding. This change forces that alteration to occur at upgrade initiation time, before any of the other upgrade process has occurred.

@cfunkhouser cfunkhouser requested review from a team as code owners June 18, 2026 23:52

@Crispy1975 Crispy1975 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM; we have a ConfigCat allowPg14LaunchOrgs flag which allows an org slug to be added. This mean we can spin up a PG14 project and then do surgery to mimic the conditions we're gonna fix.

Comment thread ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh Outdated
Comment on lines +219 to +223
# Even though the pg_net tables are created UNLOGGED, PG14 does not support
# unlogged sequences, and so they are created LOGGED. This mismatch causes
# pg_upgrade trouble. To work around it, SET LOGGED before the upgrade
# process. It (and the sequence) are then SET UNLOGGED after the upgrade
# succeeds (in complete.sh).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Q: Since the http_request_queue could be big (in some rare cases), would setting it to LOGGED have a perf impact?

IIUC, LOGGED involves a table rewrite + I/O + WAL generation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If we patch the extension as mentioned below perhaps we could avoid this step?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yeah, I would definitely expect a perf impact for this. The changes here are scoped only to upgrade time, to get us out of the breaking situation where the persistence mismatch is not accepted during the upgrade, so no database should be online and serving traffic normally with net.http_request_queue logged.

@steve-chavez

Copy link
Copy Markdown
Member

Could you clarify why is pg_upgrade a problem?

If the table is UNLOGGED + sequence LOGGED, this should run fine on pg 15.

Or is the problem restoring from pg 15, where table + sequence are UNLOGGED, to pg 14 (which doesn't supported UNLOGGED tables)?

@steve-chavez

steve-chavez commented Jun 22, 2026

Copy link
Copy Markdown
Member

Also how do we decide if an upgrade script goes into ansible or in the Nix build itself?

For example we have some upgrade testing inside the Nix expression here:

with subtest("Check upgrade path with postgresql 15"):
test.check_upgrade_path("15")

And in some cases we patch the extensions like on:

disable_timeout(STATEMENT_TIMEOUT, false);

IMO it looks it'd be better to handle this pg_net case inside the Nix expression itself since we already have a testing framework in place (and this can be ran locally).

cc @samrose

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants