Skip to content

feat: handle pg_net persistence mismatch for PG14 upgrade#2230

Open
cfunkhouser wants to merge 3 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 3 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 on lines +218 to +220
# pg_net's net.http_request_queue was created UNLOGGED on PG14. Newer pg_net
# defines it as LOGGED, so the persistence mismatch breaks pg_upgrade.
# Convert it to LOGGED before making any other changes to the source server.

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.

Confused with the above as it's not true, the table is UNLOGGED since pg_net v0.5 and has been kept that way until v0.20.3 now, see:

https://github.com/supabase/pg_net/blob/feaef7600103af5858ee7b99cf0b6700bb39f3ef/sql/pg_net.sql#L12-L19

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.

Okay, interesting. We do have cases where the table is unlogged, but the sequence is logged. I'm assuming this is because unlogged sequences were introduced in PG15, so the sequence being logged is sticky from before upgrade.

Also, since unlogged is default for pg_net, setting the table to logged and leaving it that way is likely not the whole solution. Likely, we should be setting table and sequence back to unlogged after upgrading to versions which support that. Does that make sense?

I'll make that change, and will scrub that incorrect comment.

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