Skip deleting options if columnar.options is already dropped (#5458)

Drop extension might cascade to columnar.options before dropping a
columnar table. In that case, we were getting below error when opening
columnar.options to delete records for the columnar table that we are
about to drop.: "ERROR:  could not open relation with OID 0".

I somehow reproduced this bug easily when upgrading pg, that is why
adding added the test to after_pg_upgrade_schedule.

(cherry picked from commit 25024b776e)

 Conflicts:
	src/test/regress/after_pg_upgrade_schedule
pull/5568/head
Onur Tirtir 2021-11-12 12:30:09 +03:00
parent 757446bc61
commit 3f2ac78cf6
4 changed files with 38 additions and 3 deletions

View File

@ -335,8 +335,13 @@ DeleteColumnarTableOptions(Oid regclass, bool missingOk)
*/
Assert(!IsBinaryUpgrade);
Relation columnarOptions = relation_open(ColumnarOptionsRelationId(),
RowExclusiveLock);
Relation columnarOptions = try_relation_open(ColumnarOptionsRelationId(),
RowExclusiveLock);
if (columnarOptions == NULL)
{
/* extension has been dropped */
return false;
}
/* find existing item to remove */
ScanKeyData scanKey[1] = { 0 };

View File

@ -1 +1,5 @@
test: upgrade_basic_after upgrade_columnar_after upgrade_type_after upgrade_ref2ref_after upgrade_distributed_function_after upgrade_rebalance_strategy_after upgrade_list_citus_objects
test: upgrade_basic_after upgrade_type_after upgrade_ref2ref_after upgrade_distributed_function_after upgrade_rebalance_strategy_after upgrade_list_citus_objects
# This attempts dropping citus extension (and rollbacks), so please do
# not run in parallel with any other tests.
test: upgrade_columnar_after

View File

@ -247,3 +247,15 @@ BEGIN;
-- since we run "after schedule" twice, rollback the transaction
-- to avoid getting "table already exists" errors
ROLLBACK;
BEGIN;
-- Show that we can still drop the extension after upgrading
SET client_min_messages TO WARNING;
-- Drop extension migth cascade to columnar.options before dropping a
-- columnar table. In that case, we were getting below error when opening
-- columnar.options to delete records for the columnar table that we are
-- about to drop.: "ERROR: could not open relation with OID 0".
--
-- I somehow reproduced this bug easily when upgrading pg, that is why
-- adding the test to this file.
DROP EXTENSION citus CASCADE;
ROLLBACK;

View File

@ -117,3 +117,17 @@ BEGIN;
-- since we run "after schedule" twice, rollback the transaction
-- to avoid getting "table already exists" errors
ROLLBACK;
BEGIN;
-- Show that we can still drop the extension after upgrading
SET client_min_messages TO WARNING;
-- Drop extension migth cascade to columnar.options before dropping a
-- columnar table. In that case, we were getting below error when opening
-- columnar.options to delete records for the columnar table that we are
-- about to drop.: "ERROR: could not open relation with OID 0".
--
-- I somehow reproduced this bug easily when upgrading pg, that is why
-- adding the test to this file.
DROP EXTENSION citus CASCADE;
ROLLBACK;