mirror of https://github.com/citusdata/citus.git
Move DetachPartitionCommandList back
parent
e107fb7519
commit
381871890f
|
@ -82,6 +82,7 @@
|
|||
/* managed via a GUC */
|
||||
char *EnableManualMetadataChangesForUser = "";
|
||||
|
||||
|
||||
static void EnsureSequentialModeMetadataOperations(void);
|
||||
static List * GetDistributedTableMetadataEvents(Oid relationId);
|
||||
static void EnsureObjectMetadataIsSane(int distributionArgumentIndex,
|
||||
|
@ -100,7 +101,6 @@ static GrantStmt * GenerateGrantOnSchemaStmtForRights(Oid roleOid,
|
|||
Oid schemaOid,
|
||||
char *permission,
|
||||
bool withGrantOption);
|
||||
|
||||
static void SetLocalEnableDependencyCreation(bool state);
|
||||
static char * GenerateSetRoleQuery(Oid roleOid);
|
||||
static void MetadataSyncSigTermHandler(SIGNAL_ARGS);
|
||||
|
@ -1920,6 +1920,56 @@ CreateTableMetadataOnWorkers(Oid relationId)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* DetachPartitionCommandList returns list of DETACH commands to detach partitions
|
||||
* of all distributed tables. This function is used for detaching partitions in MX
|
||||
* workers before DROPping distributed partitioned tables in them. Thus, we are
|
||||
* disabling DDL propagation to the beginning of the commands (we are also enabling
|
||||
* DDL propagation at the end of command list to swtich back to original state). As
|
||||
* an extra step, if there are no partitions to DETACH, this function simply returns
|
||||
* empty list to not disable/enable DDL propagation for nothing.
|
||||
*/
|
||||
List *
|
||||
DetachPartitionCommandList(void)
|
||||
{
|
||||
List *detachPartitionCommandList = NIL;
|
||||
List *distributedTableList = CitusTableList();
|
||||
|
||||
/* we iterate over all distributed partitioned tables and DETACH their partitions */
|
||||
CitusTableCacheEntry *cacheEntry = NULL;
|
||||
foreach_ptr(cacheEntry, distributedTableList)
|
||||
{
|
||||
if (!PartitionedTable(cacheEntry->relationId))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
List *partitionList = PartitionList(cacheEntry->relationId);
|
||||
List *detachCommands =
|
||||
GenerateDetachPartitionCommandRelationIdList(partitionList);
|
||||
detachPartitionCommandList = list_concat(detachPartitionCommandList,
|
||||
detachCommands);
|
||||
}
|
||||
|
||||
if (list_length(detachPartitionCommandList) == 0)
|
||||
{
|
||||
return NIL;
|
||||
}
|
||||
|
||||
detachPartitionCommandList = lcons(DISABLE_DDL_PROPAGATION,
|
||||
detachPartitionCommandList);
|
||||
|
||||
/*
|
||||
* We probably do not need this but as an extra precaution, we are enabling
|
||||
* DDL propagation to switch back to original state.
|
||||
*/
|
||||
detachPartitionCommandList = lappend(detachPartitionCommandList,
|
||||
ENABLE_DDL_PROPAGATION);
|
||||
|
||||
return detachPartitionCommandList;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* SyncMetadataToNodes tries recreating the metadata snapshot in the
|
||||
* metadata workers that are out of sync. Returns the result of
|
||||
|
|
|
@ -92,7 +92,6 @@ typedef struct NodeMetadata
|
|||
} NodeMetadata;
|
||||
|
||||
/* local function forward declarations */
|
||||
static List * DetachPartitionCommandList(void);
|
||||
static int ActivateNode(char *nodeName, int nodePort);
|
||||
static void RemoveNodeFromCluster(char *nodeName, int32 nodePort);
|
||||
static void ErrorIfNodeContainsNonRemovablePlacements(WorkerNode *workerNode);
|
||||
|
@ -1177,56 +1176,6 @@ ActivateNode(char *nodeName, int nodePort)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* DetachPartitionCommandList returns list of DETACH commands to detach partitions
|
||||
* of all distributed tables. This function is used for detaching partitions in MX
|
||||
* workers before DROPping distributed partitioned tables in them. Thus, we are
|
||||
* disabling DDL propagation to the beginning of the commands (we are also enabling
|
||||
* DDL propagation at the end of command list to swtich back to original state). As
|
||||
* an extra step, if there are no partitions to DETACH, this function simply returns
|
||||
* empty list to not disable/enable DDL propagation for nothing.
|
||||
*/
|
||||
static List *
|
||||
DetachPartitionCommandList(void)
|
||||
{
|
||||
List *detachPartitionCommandList = NIL;
|
||||
List *distributedTableList = CitusTableList();
|
||||
|
||||
/* we iterate over all distributed partitioned tables and DETACH their partitions */
|
||||
CitusTableCacheEntry *cacheEntry = NULL;
|
||||
foreach_ptr(cacheEntry, distributedTableList)
|
||||
{
|
||||
if (!PartitionedTable(cacheEntry->relationId))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
List *partitionList = PartitionList(cacheEntry->relationId);
|
||||
List *detachCommands =
|
||||
GenerateDetachPartitionCommandRelationIdList(partitionList);
|
||||
detachPartitionCommandList = list_concat(detachPartitionCommandList,
|
||||
detachCommands);
|
||||
}
|
||||
|
||||
if (list_length(detachPartitionCommandList) == 0)
|
||||
{
|
||||
return NIL;
|
||||
}
|
||||
|
||||
detachPartitionCommandList = lcons(DISABLE_DDL_PROPAGATION,
|
||||
detachPartitionCommandList);
|
||||
|
||||
/*
|
||||
* We probably do not need this but as an extra precaution, we are enabling
|
||||
* DDL propagation to switch back to original state.
|
||||
*/
|
||||
detachPartitionCommandList = lappend(detachPartitionCommandList,
|
||||
ENABLE_DDL_PROPAGATION);
|
||||
|
||||
return detachPartitionCommandList;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* citus_update_node moves the requested node to a different nodename and nodeport. It
|
||||
* locks to ensure no queries are running concurrently; and is intended for customers who
|
||||
|
|
|
@ -56,6 +56,7 @@ extern char * PlacementUpsertCommand(uint64 shardId, uint64 placementId, int sha
|
|||
extern char * TruncateTriggerCreateCommand(Oid relationId);
|
||||
extern void CreateShellTableOnWorkers(Oid relationId);
|
||||
extern void CreateTableMetadataOnWorkers(Oid relationId);
|
||||
extern List * DetachPartitionCommandList(void);
|
||||
extern BackgroundWorkerHandle * SpawnSyncMetadataToNodes(Oid database, Oid owner);
|
||||
extern void SyncMetadataToNodesMain(Datum main_arg);
|
||||
extern void SignalMetadataSyncDaemon(Oid database, int sig);
|
||||
|
|
Loading…
Reference in New Issue