enable local execution for DROP command on distributed & reference tables

improve-drop-trigger2
Onur Tirtir 2020-03-10 16:02:40 +03:00
parent 26cec16b16
commit 4042d21714
1 changed files with 33 additions and 7 deletions

View File

@ -396,6 +396,7 @@ DropShards(Oid relationId, char *schemaName, char *relationName,
List *dropTaskList = DropTaskList(relationId, schemaName, relationName, List *dropTaskList = DropTaskList(relationId, schemaName, relationName,
deletableShardIntervalList); deletableShardIntervalList);
bool shouldExecuteTasksLocally = ShouldExecuteTasksLocally(dropTaskList);
Task *task = NULL; Task *task = NULL;
foreach_ptr(task, dropTaskList) foreach_ptr(task, dropTaskList)
@ -423,14 +424,39 @@ DropShards(Oid relationId, char *schemaName, char *relationName,
continue; continue;
} }
const char *dropShardPlacementCommand = TaskQueryString(task); /*
ExecuteDropShardPlacementCommandRemotely(shardPlacement, * If it is a local placement of a distributed table or a reference table,
relationName, * then execute the DROP command locally.
dropShardPlacementCommand); */
if (isLocalShardPlacement && shouldExecuteTasksLocally)
if (isLocalShardPlacement)
{ {
TransactionConnectedToLocalGroup = true; List *singleTaskList = list_make1(task);
ExecuteLocalUtilityTaskList(singleTaskList);
}
else
{
/*
* Either it was not a local placement or we could not use
* local execution even if it was a local placement.
* If it is the second case, then it is possibly because in
* current transaction, some commands or queries connected
* to local group as well.
*
* Regardless of the node is a remote node or the current node,
* try to open a new connection (or use an existing one) to
* connect to that node to drop the shard placement over that
* remote connection.
*/
const char *dropShardPlacementCommand = TaskQueryString(task);
ExecuteDropShardPlacementCommandRemotely(shardPlacement,
relationName,
dropShardPlacementCommand);
if (isLocalShardPlacement)
{
TransactionConnectedToLocalGroup = true;
}
} }
DeleteShardPlacementRow(shardPlacementId); DeleteShardPlacementRow(shardPlacementId);