mirror of https://github.com/citusdata/citus.git
Check groupid existence hackily while removing metadata
parent
7e3f2486f3
commit
320a8ecdea
|
@ -2187,7 +2187,7 @@ LookupTaskPlacementHostAndPort(ShardPlacement *taskPlacement, char **nodeName,
|
|||
* there were changes in pg_dist_node and we will get those invalidations
|
||||
* in LookupNodeForGroup.
|
||||
*/
|
||||
WorkerNode *workerNode = LookupNodeForGroup(taskPlacement->groupId);
|
||||
WorkerNode *workerNode = LookupNodeForGroup(taskPlacement->groupId, false);
|
||||
*nodeName = workerNode->workerName;
|
||||
*nodePort = workerNode->workerPort;
|
||||
}
|
||||
|
|
|
@ -833,7 +833,12 @@ ResolveGroupShardPlacement(GroupShardPlacement *groupShardPlacement,
|
|||
|
||||
ShardPlacement *shardPlacement = CitusMakeNode(ShardPlacement);
|
||||
int32 groupId = groupShardPlacement->groupId;
|
||||
WorkerNode *workerNode = LookupNodeForGroup(groupId);
|
||||
WorkerNode *workerNode = LookupNodeForGroup(groupId, true);
|
||||
|
||||
if (workerNode == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* copy everything into shardPlacement but preserve the header */
|
||||
CitusNode header = shardPlacement->type;
|
||||
|
@ -929,7 +934,7 @@ LookupNodeByNodeIdOrError(uint32 nodeId)
|
|||
* appropriate error message.
|
||||
*/
|
||||
WorkerNode *
|
||||
LookupNodeForGroup(int32 groupId)
|
||||
LookupNodeForGroup(int32 groupId, bool checkExistence)
|
||||
{
|
||||
bool foundAnyNodes = false;
|
||||
|
||||
|
@ -953,10 +958,20 @@ LookupNodeForGroup(int32 groupId)
|
|||
}
|
||||
|
||||
if (!foundAnyNodes)
|
||||
{
|
||||
if (checkExistence)
|
||||
{
|
||||
ereport(NOTICE, (errmsg("there is a shard placement in node group %d but "
|
||||
"there are no nodes in that group", groupId)));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
ereport(ERROR, (errmsg("there is a shard placement in node group %d but "
|
||||
"there are no nodes in that group", groupId)));
|
||||
}
|
||||
}
|
||||
|
||||
switch (ReadFromSecondaries)
|
||||
{
|
||||
|
@ -1014,6 +1029,11 @@ ShardPlacementListIncludingOrphanedPlacements(uint64 shardId)
|
|||
tableEntry,
|
||||
shardIndex);
|
||||
|
||||
if (shardPlacement == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
placementList = lappend(placementList, shardPlacement);
|
||||
}
|
||||
|
||||
|
|
|
@ -391,7 +391,7 @@ FullShardPlacementList(Oid relationId, ArrayType *excludedShardArray)
|
|||
placementIndex++)
|
||||
{
|
||||
GroupShardPlacement *groupPlacement = &placementArray[placementIndex];
|
||||
WorkerNode *worker = LookupNodeForGroup(groupPlacement->groupId);
|
||||
WorkerNode *worker = LookupNodeForGroup(groupPlacement->groupId, false);
|
||||
ShardPlacement *placement = CitusMakeNode(ShardPlacement);
|
||||
placement->shardId = groupPlacement->shardId;
|
||||
placement->shardLength = groupPlacement->shardLength;
|
||||
|
|
|
@ -455,7 +455,7 @@ CoordinatorNodeIfAddedAsWorkerOrError()
|
|||
{
|
||||
ErrorIfCoordinatorNotAddedAsWorkerNode();
|
||||
|
||||
WorkerNode *coordinatorNode = LookupNodeForGroup(COORDINATOR_GROUP_ID);
|
||||
WorkerNode *coordinatorNode = LookupNodeForGroup(COORDINATOR_GROUP_ID, false);
|
||||
|
||||
WorkerNode *coordinatorNodeCopy = palloc0(sizeof(WorkerNode));
|
||||
*coordinatorNodeCopy = *coordinatorNode;
|
||||
|
|
|
@ -268,6 +268,12 @@ worker_drop_distributed_table_metadata_only(PG_FUNCTION_ARGS)
|
|||
uint64 shardId = *shardIdPointer;
|
||||
|
||||
List *shardPlacementList = ShardPlacementListIncludingOrphanedPlacements(shardId);
|
||||
if (shardPlacementList == NULL)
|
||||
{
|
||||
ereport(NOTICE, (errmsg("placement for relation with oid %d does not exist, skipping", relationId)));
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
ShardPlacement *placement = NULL;
|
||||
foreach_ptr(placement, shardPlacementList)
|
||||
{
|
||||
|
|
|
@ -211,7 +211,7 @@ extern bool HasAnyNodes(void);
|
|||
extern HTAB * GetWorkerNodeHash(void);
|
||||
extern WorkerNode * LookupNodeByNodeId(uint32 nodeId);
|
||||
extern WorkerNode * LookupNodeByNodeIdOrError(uint32 nodeId);
|
||||
extern WorkerNode * LookupNodeForGroup(int32 groupId);
|
||||
extern WorkerNode * LookupNodeForGroup(int32 groupId, bool checkExistence);
|
||||
|
||||
/* namespace oids */
|
||||
extern Oid CitusCatalogNamespaceId(void);
|
||||
|
|
|
@ -75,7 +75,7 @@ extern Oid GetAttributeTypeOid(Oid relationId, AttrNumber attnum);
|
|||
#define REMOVE_ALL_CLUSTERED_TABLES_ONLY_COMMAND \
|
||||
"SELECT worker_drop_distributed_table_only(logicalrelid::regclass::text) FROM pg_dist_partition"
|
||||
#define REMOVE_ALL_CLUSTERED_TABLES_METADATA_ONLY_COMMAND \
|
||||
"SELECT worker_drop_distributed_table_metadata_only(logicalrelid) FROM pg_dist_partition"
|
||||
"SELECT worker_drop_distributed_table_metadata_only(logicalrelid::oid) FROM pg_dist_partition"
|
||||
#define REMOVE_ALL_CLUSTERED_TABLES_COMMAND \
|
||||
"SELECT worker_drop_distributed_table(logicalrelid::regclass::text) FROM pg_dist_partition"
|
||||
#define DISABLE_DDL_PROPAGATION "SET citus.enable_ddl_propagation TO 'off'"
|
||||
|
|
Loading…
Reference in New Issue