Update start_metadata and stop_metadata command definitions

ref_on_buraks
Burak Velioglu 2022-01-27 12:01:56 +03:00
parent 6d4f70363e
commit 277bdf5bb1
No known key found for this signature in database
GPG Key ID: F6827E620F6549C6
3 changed files with 43 additions and 8 deletions

View File

@ -106,6 +106,7 @@ static RoleSpec * GetRoleSpecObjectForGrantStmt(Oid roleOid);
static List * GenerateGrantOnSchemaQueriesFromAclItem(Oid schemaOid, static List * GenerateGrantOnSchemaQueriesFromAclItem(Oid schemaOid,
AclItem *aclItem); AclItem *aclItem);
static void SetLocalEnableDependencyCreation(bool state); static void SetLocalEnableDependencyCreation(bool state);
static void SetLocalReplicateReferenceTablesOnActivate(bool state);
static char * GenerateSetRoleQuery(Oid roleOid); static char * GenerateSetRoleQuery(Oid roleOid);
static void MetadataSyncSigTermHandler(SIGNAL_ARGS); static void MetadataSyncSigTermHandler(SIGNAL_ARGS);
static void MetadataSyncSigAlrmHandler(SIGNAL_ARGS); static void MetadataSyncSigAlrmHandler(SIGNAL_ARGS);
@ -162,7 +163,12 @@ start_metadata_sync_to_node(PG_FUNCTION_ARGS)
char *nodeNameString = text_to_cstring(nodeName); char *nodeNameString = text_to_cstring(nodeName);
SyncNodeMetadataToNode(nodeNameString, nodePort); bool prevReplicateRefTablesOnActivate = ReplicateReferenceTablesOnActivate;
SetLocalReplicateReferenceTablesOnActivate(false);
ActivateNode(nodeNameString, nodePort);
SetLocalReplicateReferenceTablesOnActivate(prevReplicateRefTablesOnActivate);
PG_RETURN_VOID(); PG_RETURN_VOID();
} }
@ -516,12 +522,28 @@ DropMetadataSnapshotOnNode(WorkerNode *workerNode)
char *userName = CurrentUserName(); char *userName = CurrentUserName();
/* generate the queries which drop the metadata */ /*
List *dropMetadataCommandList = NodeMetadataDropCommands(); * Detach partitions, break dependencies between sequences and table then
* remove shell tables first.
*/
List *dropMetadataCommandList = DetachPartitionCommandList();
dropMetadataCommandList = lappend(dropMetadataCommandList, dropMetadataCommandList = lappend(dropMetadataCommandList,
LocalGroupIdUpdateCommand(0)); BREAK_CITUS_TABLE_SEQUENCE_DEPENDENCY_COMMAND);
dropMetadataCommandList = lappend(dropMetadataCommandList,
REMOVE_ALL_SHELL_TABLES_COMMAND);
dropMetadataCommandList = list_concat(dropMetadataCommandList,
NodeMetadataDropCommands());
dropMetadataCommandList = lappend(dropMetadataCommandList, LocalGroupIdUpdateCommand(
0));
/* remove all dist table and object/table related metadata afterwards */
dropMetadataCommandList = lappend(dropMetadataCommandList, DELETE_ALL_PARTITIONS);
dropMetadataCommandList = lappend(dropMetadataCommandList, DELETE_ALL_SHARDS);
dropMetadataCommandList = lappend(dropMetadataCommandList, DELETE_ALL_PLACEMENTS);
dropMetadataCommandList = lappend(dropMetadataCommandList,
DELETE_ALL_DISTRIBUTED_OBJECTS);
EnsureSequentialModeMetadataOperations();
SendOptionalMetadataCommandListToWorkerInCoordinatedTransaction( SendOptionalMetadataCommandListToWorkerInCoordinatedTransaction(
workerNode->workerName, workerNode->workerName,
workerNode->workerPort, workerNode->workerPort,
@ -1854,6 +1876,20 @@ SetLocalEnableDependencyCreation(bool state)
} }
/*
* SetLocalReplicateReferenceTablesOnActivate sets the
* replicate_reference_tables_on_activate locally
*/
void
SetLocalReplicateReferenceTablesOnActivate(bool state)
{
set_config_option("citus.replicate_reference_tables_on_activate",
state == true ? "on" : "off",
(superuser() ? PGC_SUSET : PGC_USERSET), PGC_S_SESSION,
GUC_ACTION_LOCAL, true, 0, false);
}
static char * static char *
GenerateSetRoleQuery(Oid roleOid) GenerateSetRoleQuery(Oid roleOid)
{ {

View File

@ -92,7 +92,6 @@ typedef struct NodeMetadata
} NodeMetadata; } NodeMetadata;
/* local function forward declarations */ /* local function forward declarations */
static int ActivateNode(char *nodeName, int nodePort);
static void RemoveNodeFromCluster(char *nodeName, int32 nodePort); static void RemoveNodeFromCluster(char *nodeName, int32 nodePort);
static void ErrorIfNodeContainsNonRemovablePlacements(WorkerNode *workerNode); static void ErrorIfNodeContainsNonRemovablePlacements(WorkerNode *workerNode);
static bool PlacementHasActivePlacementOnAnotherGroup(GroupShardPlacement static bool PlacementHasActivePlacementOnAnotherGroup(GroupShardPlacement
@ -799,7 +798,6 @@ SyncObjectDependenciesToNode(WorkerNode *workerNode)
return; return;
} }
EnsureNoModificationsHaveBeenDone();
Assert(ShouldPropagate()); Assert(ShouldPropagate());
List *commandList = SyncObjectDependenciesCommandList(workerNode); List *commandList = SyncObjectDependenciesCommandList(workerNode);
@ -1054,7 +1052,7 @@ PrimaryNodeForGroup(int32 groupId, bool *groupContainsNodes)
* includes only replicating the reference tables and setting isactive column of the * includes only replicating the reference tables and setting isactive column of the
* given node. * given node.
*/ */
static int int
ActivateNode(char *nodeName, int nodePort) ActivateNode(char *nodeName, int nodePort)
{ {
bool isActive = true; bool isActive = true;

View File

@ -63,6 +63,7 @@ extern char *WorkerListFileName;
extern char *CurrentCluster; extern char *CurrentCluster;
extern bool ReplicateReferenceTablesOnActivate; extern bool ReplicateReferenceTablesOnActivate;
extern int ActivateNode(char *nodeName, int nodePort);
/* Function declarations for finding worker nodes to place shards on */ /* Function declarations for finding worker nodes to place shards on */
extern WorkerNode * WorkerGetRandomCandidateNode(List *currentNodeList); extern WorkerNode * WorkerGetRandomCandidateNode(List *currentNodeList);