feat: handle pg_net persistence mismatch for PG14 upgrade#2230
feat: handle pg_net persistence mismatch for PG14 upgrade#2230cfunkhouser wants to merge 6 commits into
Conversation
Crispy1975
left a comment
There was a problem hiding this comment.
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.
…e-mismatch-before-pg14-auto-upgrades
…e-mismatch-before-pg14-auto-upgrades
| # 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). |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
If we patch the extension as mentioned below perhaps we could avoid this step?
There was a problem hiding this comment.
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.
|
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)? |
|
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: postgres/nix/ext/tests/postgis.nix Lines 99 to 100 in e157099 And in some cases we patch the extensions like on: 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 |
Execute
ALTER TABLE net.http_request_queue SET LOGGEDon PG14 databases before upgrade.There is a state mismatch in which
net.http_request_queue_id_seqsequence is logged, but the tablenet.http_request_queueis not. This mismatch preventspg_upgradefrom proceeding. This change forces that alteration to occur at upgrade initiation time, before any of the other upgrade process has occurred.