RE: [PoC] pg_upgrade: allow to upgrade publisher node
Hayato Kuroda (Fujitsu) <kuroda.hayato@fujitsu.com>
From: "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>
To: 'Amit Kapila' <amit.kapila16@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Julien Rouhaud <rjuju123@gmail.com>, vignesh C <vignesh21@gmail.com>
Date: 2023-08-03T09:28:33Z
Lists: pgsql-hackers
Attachments
- test_0803.sh (application/octet-stream)
Dear Amit, > I see your point related to WALAVAIL_REMOVED status of the slot but > did you test the scenario I have explained in my comment? Basically, I > want to know whether it can impact the user in some way. So, please > check whether the corresponding subscriptions will be allowed to drop. > You can test it both before and after the upgrade. Yeah, this is a real issue. I have tested and confirmed the expected things. Even if the status of the slot is 'lost', it may be needed for dropping subscriptions properly. * before upgrading, the subscription which refers the lost slot could be dropped * after upgrading, the subscription could not be dropped as-is. users must ALTER SUBSCRIPTION sub SET (slot_name = NONE); Followings are the stepped what I did: ## Setup 1. constructed a logical replication system 2. disabled the subscriber once 3. consumed many WALs so that the status of slot became 'lost' ``` publisher=# SELECT slot_name, wal_status FROM pg_replication_slots ; slot_name | wal_status -----------+------------ sub | lost (1 row) ``` # testcase a - try to drop sub. before upgrading a-1. enabled the subscriber again. At that time following messages are shown on subscriber log: ``` ERROR: could not start WAL streaming: ERROR: can no longer get changes from replication slot "sub" DETAIL: This slot has been invalidated because it exceeded the maximum reserved size. ``` a-2. did DROP SUBSCRIPTION ... a-3. succeeded. ``` subscriber=# DROP SUBSCRIPTION sub; NOTICE: dropped replication slot "sub" on publisher DROP SUBSCRIPTION ``` # testcase b - try to drop sub. after upgrading b-1. did pg_upgrade command b-2. enabled the subscriber. From that point an apply worker connected to new node... b-3. did DROP SUBSCRIPTION ... b-4. failed with the message: ``` subscriber=# DROP SUBSCRIPTION sub; ERROR: could not drop replication slot "sub" on publisher: ERROR: replication slot "sub" does not exist ``` The workaround was to disassociate the slot, which was written in the document. ``` subscriber =# ALTER SUBSCRIPTION sub DISABLE; ALTER SUBSCRIPTION subscriber =# ALTER SUBSCRIPTION sub SET (slot_name = NONE); ALTER SUBSCRIPTION subscriber =# DROP SUBSCRIPTION sub; DROP SUBSCRIPTION ``` PSA the script for emulating above tests. Best Regards, Hayato Kuroda FUJITSU LIMITED
Commits
-
Fix issues in binary_upgrade_logical_slot_has_caught_up().
- 0bf62460bb9e 17.0 landed
-
Fix a random failure in 003_logical_slots.pl.
- 63c5df126abb 17.0 landed
-
Fix a test in 003_logical_slots.
- 3e36e48d8efe 17.0 landed
-
Fix uninitialized slot array access during the upgrade.
- a7db71ed2787 17.0 landed
-
Fix the test 003_logical_slots.
- 8af917be6bad 17.0 landed
-
Commit b195e6d482 forgot to update meson.build.
- 8949b978ff49 17.0 landed
-
Use shorter file names in the upgrade logical slots test.
- b195e6d482b8 17.0 landed
-
Migrate logical slots to the new node during an upgrade.
- 29d0a77fa660 17.0 landed
-
Flush logical slots to disk during a shutdown checkpoint if required.
- e0b2eed047df 17.0 landed
-
Prevent possibility of panics during shutdown checkpoint.
- c6c333436491 10.0 cited