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
	src/test/regress/expected/upgrade_columnar_after.out
	src/test/regress/sql/upgrade_columnar_after.sql
onder_10_1_comm
Onur Tirtir 2021-11-12 12:30:09 +03:00
parent dd53a1ad1f
commit 854eec7380
4 changed files with 37 additions and 3 deletions

View File

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

@ -141,3 +141,15 @@ SELECT count(*), sum(a), sum(b) FROM test_options_2;
20000 | 100010000 | 65015 20000 | 100010000 | 65015
(1 row) (1 row)
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

@ -39,3 +39,16 @@ SELECT * FROM columnar.options WHERE regclass = 'test_options_2'::regclass;
VACUUM VERBOSE test_options_2; VACUUM VERBOSE test_options_2;
SELECT count(*), sum(a), sum(b) FROM test_options_2; SELECT count(*), sum(a), sum(b) FROM test_options_2;
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;