mirror of https://github.com/citusdata/citus.git
Remove AllFinalizedlacementsAccessible Function
This change removes AllFinalizedPlacementsAccessible function since, we open connections to all shard placements before any command is sent so we immediately error out if a shard placement is not accessible.pull/686/head
parent
40f8149320
commit
8a590c9e5b
|
@ -92,7 +92,6 @@ static void SetLocalCommitProtocolTo2PC(void);
|
||||||
static bool ExecuteCommandOnWorkerShards(Oid relationId, const char *commandString);
|
static bool ExecuteCommandOnWorkerShards(Oid relationId, const char *commandString);
|
||||||
static void ExecuteCommandOnShardPlacements(StringInfo applyCommand, uint64 shardId,
|
static void ExecuteCommandOnShardPlacements(StringInfo applyCommand, uint64 shardId,
|
||||||
ShardConnections *shardConnections);
|
ShardConnections *shardConnections);
|
||||||
static bool AllFinalizedPlacementsAccessible(Oid relationId);
|
|
||||||
static void RangeVarCallbackForDropIndex(const RangeVar *rel, Oid relOid, Oid oldRelOid,
|
static void RangeVarCallbackForDropIndex(const RangeVar *rel, Oid relOid, Oid oldRelOid,
|
||||||
void *arg);
|
void *arg);
|
||||||
static void CheckCopyPermissions(CopyStmt *copyStatement);
|
static void CheckCopyPermissions(CopyStmt *copyStatement);
|
||||||
|
@ -1057,19 +1056,10 @@ ExecuteDistributedDDLCommand(Oid relationId, const char *ddlCommandString,
|
||||||
bool isTopLevel)
|
bool isTopLevel)
|
||||||
{
|
{
|
||||||
bool executionOK = false;
|
bool executionOK = false;
|
||||||
bool allPlacementsAccessible = false;
|
|
||||||
|
|
||||||
PreventTransactionChain(isTopLevel, "distributed DDL commands");
|
PreventTransactionChain(isTopLevel, "distributed DDL commands");
|
||||||
SetLocalCommitProtocolTo2PC();
|
SetLocalCommitProtocolTo2PC();
|
||||||
|
|
||||||
allPlacementsAccessible = AllFinalizedPlacementsAccessible(relationId);
|
|
||||||
if (!allPlacementsAccessible)
|
|
||||||
{
|
|
||||||
ereport(ERROR, (errmsg("cannot execute command: %s", ddlCommandString),
|
|
||||||
errdetail("All finalized shard placements need to be accessible "
|
|
||||||
"to execute DDL commands on distributed tables.")));
|
|
||||||
}
|
|
||||||
|
|
||||||
executionOK = ExecuteCommandOnWorkerShards(relationId, ddlCommandString);
|
executionOK = ExecuteCommandOnWorkerShards(relationId, ddlCommandString);
|
||||||
|
|
||||||
/* if command could not be executed on any finalized shard placement, error out */
|
/* if command could not be executed on any finalized shard placement, error out */
|
||||||
|
@ -1220,64 +1210,6 @@ ExecuteCommandOnShardPlacements(StringInfo applyCommand, uint64 shardId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* AllFinalizedPlacementsAccessible returns true if all the finalized shard
|
|
||||||
* placements for a given relation are accessible. Otherwise, the function
|
|
||||||
* returns false. To do so, the function first gets a list of responsive
|
|
||||||
* worker nodes and then checks if all the finalized shard placements lie
|
|
||||||
* on those worker nodes.
|
|
||||||
*/
|
|
||||||
static bool
|
|
||||||
AllFinalizedPlacementsAccessible(Oid relationId)
|
|
||||||
{
|
|
||||||
bool allPlacementsAccessible = true;
|
|
||||||
ListCell *shardCell = NULL;
|
|
||||||
List *responsiveNodeList = ResponsiveWorkerNodeList();
|
|
||||||
|
|
||||||
List *shardList = LoadShardList(relationId);
|
|
||||||
foreach(shardCell, shardList)
|
|
||||||
{
|
|
||||||
List *shardPlacementList = NIL;
|
|
||||||
ListCell *shardPlacementCell = NULL;
|
|
||||||
uint64 *shardIdPointer = (uint64 *) lfirst(shardCell);
|
|
||||||
uint64 shardId = (*shardIdPointer);
|
|
||||||
|
|
||||||
shardPlacementList = FinalizedShardPlacementList(shardId);
|
|
||||||
foreach(shardPlacementCell, shardPlacementList)
|
|
||||||
{
|
|
||||||
ListCell *responsiveNodeCell = NULL;
|
|
||||||
bool placementAccessible = false;
|
|
||||||
ShardPlacement *placement = (ShardPlacement *) lfirst(shardPlacementCell);
|
|
||||||
|
|
||||||
/* verify that the placement lies on one of the responsive worker nodes */
|
|
||||||
foreach(responsiveNodeCell, responsiveNodeList)
|
|
||||||
{
|
|
||||||
WorkerNode *node = (WorkerNode *) lfirst(responsiveNodeCell);
|
|
||||||
if (strncmp(node->workerName, placement->nodeName, WORKER_LENGTH) == 0 &&
|
|
||||||
node->workerPort == placement->nodePort)
|
|
||||||
{
|
|
||||||
placementAccessible = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!placementAccessible)
|
|
||||||
{
|
|
||||||
allPlacementsAccessible = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!allPlacementsAccessible)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return allPlacementsAccessible;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Before acquiring a table lock, check whether we have sufficient rights.
|
* Before acquiring a table lock, check whether we have sufficient rights.
|
||||||
* In the case of DROP INDEX, also try to lock the table before the index.
|
* In the case of DROP INDEX, also try to lock the table before the index.
|
||||||
|
|
Loading…
Reference in New Issue