From 541b1525cb69c80162f0199b53d6a8dbf5b42095 Mon Sep 17 00:00:00 2001 From: Onder Kalaci Date: Wed, 17 Aug 2022 11:18:04 +0200 Subject: [PATCH] acquire lock on a ref table --- src/backend/distributed/utils/reference_table_utils.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/backend/distributed/utils/reference_table_utils.c b/src/backend/distributed/utils/reference_table_utils.c index fd683cc3b..f5720539b 100644 --- a/src/backend/distributed/utils/reference_table_utils.c +++ b/src/backend/distributed/utils/reference_table_utils.c @@ -112,6 +112,14 @@ EnsureReferenceTablesExistOnAllNodesExtended(char transferMode) return; } + /* + * Don't let this table dropped, if dropped retry instead of + * erroring out unless we find 1 table. + */ + if (!ConditionalLockRelationOid(referenceTableId, AccessShareLock)) + { + elog(ERROR, "table droppeed concurrently"); + } /* * Most of the time this function should result in a conclusion where we do not need