All users of WorkerNodeHash take an AccessShareLock

The metadata cache simulates a SELECT on pg_dist_node. Now the locks it
takes also simulate that SELECT.
pull/1519/head
Brian Cloutier 2017-08-04 17:37:49 +03:00 committed by Brian Cloutier
parent 5914c992e6
commit a3e9bef685
3 changed files with 7 additions and 3 deletions

View File

@ -174,8 +174,6 @@ DistributedTableSize(Oid relationId, char *sizeQuery)
ErrorIfNotSuitableToGetSize(relationId);
LockRelationOid(DistNodeRelationId(), AccessShareLock);
workerNodeList = ActivePrimaryNodeList();
foreach(workerNodeCell, workerNodeList)

View File

@ -43,6 +43,7 @@
#include "nodes/makefuncs.h"
#include "parser/parse_func.h"
#include "parser/parse_type.h"
#include "storage/lmgr.h"
#include "utils/builtins.h"
#include "utils/catcache.h"
#include "utils/datum.h"
@ -2272,6 +2273,12 @@ GetWorkerNodeHash(void)
{
InitializeCaches(); /* ensure relevant callbacks are registered */
/*
* Simulate a SELECT from pg_dist_node, ensure pg_dist_node doesn't change while our
* caller is using WorkerNodeHash.
*/
LockRelationOid(DistNodeRelationId(), AccessShareLock);
/*
* We might have some concurrent metadata changes. In order to get the changes,
* we first need to accept the cache invalidation messages.

View File

@ -230,7 +230,6 @@ ReplicateShardToAllWorkers(ShardInterval *shardInterval)
List *workerNodeList = NULL;
ListCell *workerNodeCell = NULL;
LockRelationOid(DistNodeRelationId(), AccessShareLock);
workerNodeList = ActivePrimaryNodeList();
/*