Refactor: ReplicateShardToAllWorkers more explicitly locks pg_dist_node

pull/1519/head
Brian Cloutier 2017-08-03 11:17:34 +03:00 committed by Brian Cloutier
parent f87fefa323
commit 94947c0d54
1 changed files with 5 additions and 5 deletions

View File

@ -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);
}