From 94947c0d540e362f6e48f279d546acb1596bc593 Mon Sep 17 00:00:00 2001 From: Brian Cloutier Date: Thu, 3 Aug 2017 11:17:34 +0300 Subject: [PATCH] Refactor: ReplicateShardToAllWorkers more explicitly locks pg_dist_node --- src/backend/distributed/utils/reference_table_utils.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/backend/distributed/utils/reference_table_utils.c b/src/backend/distributed/utils/reference_table_utils.c index 6ea1d6eb6..a9172a0a1 100644 --- a/src/backend/distributed/utils/reference_table_utils.c +++ b/src/backend/distributed/utils/reference_table_utils.c @@ -28,6 +28,7 @@ #include "distributed/transaction_management.h" #include "distributed/worker_manager.h" #include "distributed/worker_transaction.h" +#include "storage/lmgr.h" #include "utils/fmgroids.h" #include "utils/lsyscache.h" #include "utils/rel.h" @@ -226,11 +227,12 @@ ReplicateSingleShardTableToAllWorkers(Oid relationId) static void ReplicateShardToAllWorkers(ShardInterval *shardInterval) { - /* we do not use pgDistNode, we only obtain a lock on it to prevent modifications */ - Relation pgDistNode = heap_open(DistNodeRelationId(), AccessShareLock); - List *workerNodeList = ActivePrimaryNodeList(); + List *workerNodeList = NULL; ListCell *workerNodeCell = NULL; + LockRelationOid(DistNodeRelationId(), AccessShareLock); + workerNodeList = ActivePrimaryNodeList(); + /* * We will iterate over all worker nodes and if healthy placement is not exist at * given node we will copy the shard to that node. Then we will also modify @@ -245,8 +247,6 @@ ReplicateShardToAllWorkers(ShardInterval *shardInterval) ReplicateShardToNode(shardInterval, nodeName, nodePort); } - - heap_close(pgDistNode, NoLock); }