mirror of https://github.com/citusdata/citus.git
Update metadata sync function names
parent
016c6179de
commit
5d1eae732c
|
@ -91,7 +91,7 @@ static char * SchemaOwnerName(Oid objectId);
|
||||||
static bool HasMetadataWorkers(void);
|
static bool HasMetadataWorkers(void);
|
||||||
static bool ShouldSyncTableMetadataInternal(bool hashDistributed,
|
static bool ShouldSyncTableMetadataInternal(bool hashDistributed,
|
||||||
bool citusTableWithNoDistKey);
|
bool citusTableWithNoDistKey);
|
||||||
static bool SyncMetadataSnapshotToNode(WorkerNode *workerNode, bool raiseOnError);
|
static bool SyncNodeMetadataSnapshotToNode(WorkerNode *workerNode, bool raiseOnError);
|
||||||
static void DropMetadataSnapshotOnNode(WorkerNode *workerNode);
|
static void DropMetadataSnapshotOnNode(WorkerNode *workerNode);
|
||||||
static char * CreateSequenceDependencyCommand(Oid relationId, Oid sequenceId,
|
static char * CreateSequenceDependencyCommand(Oid relationId, Oid sequenceId,
|
||||||
char *columnName);
|
char *columnName);
|
||||||
|
@ -235,7 +235,7 @@ SyncNodeMetadataToNode(const char *nodeNameString, int32 nodePort)
|
||||||
|
|
||||||
/* fail if metadata synchronization doesn't succeed */
|
/* fail if metadata synchronization doesn't succeed */
|
||||||
bool raiseInterrupts = true;
|
bool raiseInterrupts = true;
|
||||||
SyncMetadataSnapshotToNode(workerNode, raiseInterrupts);
|
SyncNodeMetadataSnapshotToNode(workerNode, raiseInterrupts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -442,25 +442,25 @@ ShouldSyncTableMetadataInternal(bool hashDistributed, bool citusTableWithNoDistK
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SyncMetadataSnapshotToNode does the following:
|
* SyncNodeMetadataSnapshotToNode does the following:
|
||||||
* 1. Sets the localGroupId on the worker so the worker knows which tuple in
|
* 1. Sets the localGroupId on the worker so the worker knows which tuple in
|
||||||
* pg_dist_node represents itself.
|
* pg_dist_node represents itself.
|
||||||
* 2. Recreates the distributed metadata on the given worker.
|
* 2. Recreates the distributed metadata on the given worker.
|
||||||
* If raiseOnError is true, it errors out if synchronization fails.
|
* If raiseOnError is true, it errors out if synchronization fails.
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
SyncMetadataSnapshotToNode(WorkerNode *workerNode, bool raiseOnError)
|
SyncNodeMetadataSnapshotToNode(WorkerNode *workerNode, bool raiseOnError)
|
||||||
{
|
{
|
||||||
char *currentUser = CurrentUserName();
|
char *currentUser = CurrentUserName();
|
||||||
|
|
||||||
/* generate and add the local group id's update query */
|
/* generate and add the local group id's update query */
|
||||||
char *localGroupIdUpdateCommand = LocalGroupIdUpdateCommand(workerNode->groupId);
|
char *localGroupIdUpdateCommand = LocalGroupIdUpdateCommand(workerNode->groupId);
|
||||||
|
|
||||||
/* generate the queries which drop the metadata */
|
/* generate the queries which drop the node metadata */
|
||||||
List *dropMetadataCommandList = MetadataDropCommands();
|
List *dropMetadataCommandList = NodeMetadataDropCommands();
|
||||||
|
|
||||||
/* generate the queries which create the metadata from scratch */
|
/* generate the queries which create the node metadata from scratch */
|
||||||
List *createMetadataCommandList = MetadataCreateCommands();
|
List *createMetadataCommandList = NodeMetadataCreateCommands();
|
||||||
|
|
||||||
List *recreateMetadataSnapshotCommandList = list_make1(localGroupIdUpdateCommand);
|
List *recreateMetadataSnapshotCommandList = list_make1(localGroupIdUpdateCommand);
|
||||||
recreateMetadataSnapshotCommandList = list_concat(recreateMetadataSnapshotCommandList,
|
recreateMetadataSnapshotCommandList = list_concat(recreateMetadataSnapshotCommandList,
|
||||||
|
@ -506,7 +506,7 @@ DropMetadataSnapshotOnNode(WorkerNode *workerNode)
|
||||||
char *userName = CurrentUserName();
|
char *userName = CurrentUserName();
|
||||||
|
|
||||||
/* generate the queries which drop the metadata */
|
/* generate the queries which drop the metadata */
|
||||||
List *dropMetadataCommandList = MetadataDropCommands();
|
List *dropMetadataCommandList = NodeMetadataDropCommands();
|
||||||
|
|
||||||
dropMetadataCommandList = lappend(dropMetadataCommandList,
|
dropMetadataCommandList = lappend(dropMetadataCommandList,
|
||||||
LocalGroupIdUpdateCommand(0));
|
LocalGroupIdUpdateCommand(0));
|
||||||
|
@ -520,7 +520,7 @@ DropMetadataSnapshotOnNode(WorkerNode *workerNode)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MetadataCreateCommands returns list of queries that are
|
* NodeMetadataCreateCommands returns list of queries that are
|
||||||
* required to create the current metadata snapshot of the node that the
|
* required to create the current metadata snapshot of the node that the
|
||||||
* function is called. The metadata snapshot commands includes the
|
* function is called. The metadata snapshot commands includes the
|
||||||
* following queries:
|
* following queries:
|
||||||
|
@ -528,7 +528,7 @@ DropMetadataSnapshotOnNode(WorkerNode *workerNode)
|
||||||
* (i) Query that populates pg_dist_node table
|
* (i) Query that populates pg_dist_node table
|
||||||
*/
|
*/
|
||||||
List *
|
List *
|
||||||
MetadataCreateCommands(void)
|
NodeMetadataCreateCommands(void)
|
||||||
{
|
{
|
||||||
List *metadataSnapshotCommandList = NIL;
|
List *metadataSnapshotCommandList = NIL;
|
||||||
bool includeNodesFromOtherClusters = true;
|
bool includeNodesFromOtherClusters = true;
|
||||||
|
@ -687,14 +687,14 @@ GetDistributedTableMetadataEvents(Oid relationId)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MetadataDropCommands returns list of queries that are required to
|
* NodeMetadataDropCommands returns list of queries that are required to
|
||||||
* drop all the metadata of the node that are not related to clustered tables.
|
* drop all the metadata of the node that are not related to clustered tables.
|
||||||
* The drop metadata snapshot commands includes the following queries:
|
* The drop metadata snapshot commands includes the following queries:
|
||||||
*
|
*
|
||||||
* (i) Queries that delete all the rows from pg_dist_node table
|
* (i) Queries that delete all the rows from pg_dist_node table
|
||||||
*/
|
*/
|
||||||
List *
|
List *
|
||||||
MetadataDropCommands(void)
|
NodeMetadataDropCommands(void)
|
||||||
{
|
{
|
||||||
List *dropSnapshotCommandList = NIL;
|
List *dropSnapshotCommandList = NIL;
|
||||||
|
|
||||||
|
@ -1971,7 +1971,7 @@ DetachPartitionCommandList(void)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SyncMetadataToNodes tries recreating the metadata snapshot in the
|
* SyncNodeMetadataToNodes tries recreating the metadata snapshot in the
|
||||||
* metadata workers that are out of sync. Returns the result of
|
* metadata workers that are out of sync. Returns the result of
|
||||||
* synchronization.
|
* synchronization.
|
||||||
*
|
*
|
||||||
|
@ -1980,7 +1980,7 @@ DetachPartitionCommandList(void)
|
||||||
* goes wrong.
|
* goes wrong.
|
||||||
*/
|
*/
|
||||||
static MetadataSyncResult
|
static MetadataSyncResult
|
||||||
SyncMetadataToNodes(void)
|
SyncNodeMetadataToNodes(void)
|
||||||
{
|
{
|
||||||
MetadataSyncResult result = METADATA_SYNC_SUCCESS;
|
MetadataSyncResult result = METADATA_SYNC_SUCCESS;
|
||||||
if (!IsCoordinator())
|
if (!IsCoordinator())
|
||||||
|
@ -2006,7 +2006,7 @@ SyncMetadataToNodes(void)
|
||||||
if (workerNode->hasMetadata && !workerNode->metadataSynced)
|
if (workerNode->hasMetadata && !workerNode->metadataSynced)
|
||||||
{
|
{
|
||||||
bool raiseInterrupts = false;
|
bool raiseInterrupts = false;
|
||||||
if (!SyncMetadataSnapshotToNode(workerNode, raiseInterrupts))
|
if (!SyncNodeMetadataSnapshotToNode(workerNode, raiseInterrupts))
|
||||||
{
|
{
|
||||||
ereport(WARNING, (errmsg("failed to sync metadata to %s:%d",
|
ereport(WARNING, (errmsg("failed to sync metadata to %s:%d",
|
||||||
workerNode->workerName,
|
workerNode->workerName,
|
||||||
|
@ -2041,11 +2041,11 @@ SyncMetadataToNodes(void)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SyncMetadataToNodesMain is the main function for syncing metadata to
|
* SyncNodeMetadataToNodesMain is the main function for syncing node metadata to
|
||||||
* MX nodes. It retries until success and then exits.
|
* MX nodes. It retries until success and then exits.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
SyncMetadataToNodesMain(Datum main_arg)
|
SyncNodeMetadataToNodesMain(Datum main_arg)
|
||||||
{
|
{
|
||||||
Oid databaseOid = DatumGetObjectId(main_arg);
|
Oid databaseOid = DatumGetObjectId(main_arg);
|
||||||
|
|
||||||
|
@ -2086,7 +2086,7 @@ SyncMetadataToNodesMain(Datum main_arg)
|
||||||
{
|
{
|
||||||
UseCoordinatedTransaction();
|
UseCoordinatedTransaction();
|
||||||
|
|
||||||
MetadataSyncResult result = SyncMetadataToNodes();
|
MetadataSyncResult result = SyncNodeMetadataToNodes();
|
||||||
syncedAllNodes = (result == METADATA_SYNC_SUCCESS);
|
syncedAllNodes = (result == METADATA_SYNC_SUCCESS);
|
||||||
|
|
||||||
/* we use LISTEN/NOTIFY to wait for metadata syncing in tests */
|
/* we use LISTEN/NOTIFY to wait for metadata syncing in tests */
|
||||||
|
@ -2174,11 +2174,11 @@ MetadataSyncSigAlrmHandler(SIGNAL_ARGS)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SpawnSyncMetadataToNodes starts a background worker which runs metadata
|
* SpawnSyncNodeMetadataToNodes starts a background worker which runs node metadata
|
||||||
* sync. On success it returns workers' handle. Otherwise it returns NULL.
|
* sync. On success it returns workers' handle. Otherwise it returns NULL.
|
||||||
*/
|
*/
|
||||||
BackgroundWorkerHandle *
|
BackgroundWorkerHandle *
|
||||||
SpawnSyncMetadataToNodes(Oid database, Oid extensionOwner)
|
SpawnSyncNodeMetadataToNodes(Oid database, Oid extensionOwner)
|
||||||
{
|
{
|
||||||
BackgroundWorker worker;
|
BackgroundWorker worker;
|
||||||
BackgroundWorkerHandle *handle = NULL;
|
BackgroundWorkerHandle *handle = NULL;
|
||||||
|
@ -2196,7 +2196,7 @@ SpawnSyncMetadataToNodes(Oid database, Oid extensionOwner)
|
||||||
worker.bgw_restart_time = BGW_NEVER_RESTART;
|
worker.bgw_restart_time = BGW_NEVER_RESTART;
|
||||||
strcpy_s(worker.bgw_library_name, sizeof(worker.bgw_library_name), "citus");
|
strcpy_s(worker.bgw_library_name, sizeof(worker.bgw_library_name), "citus");
|
||||||
strcpy_s(worker.bgw_function_name, sizeof(worker.bgw_library_name),
|
strcpy_s(worker.bgw_function_name, sizeof(worker.bgw_library_name),
|
||||||
"SyncMetadataToNodesMain");
|
"SyncNodeMetadataToNodesMain");
|
||||||
worker.bgw_main_arg = ObjectIdGetDatum(MyDatabaseId);
|
worker.bgw_main_arg = ObjectIdGetDatum(MyDatabaseId);
|
||||||
memcpy_s(worker.bgw_extra, sizeof(worker.bgw_extra), &extensionOwner,
|
memcpy_s(worker.bgw_extra, sizeof(worker.bgw_extra), &extensionOwner,
|
||||||
sizeof(Oid));
|
sizeof(Oid));
|
||||||
|
|
|
@ -50,8 +50,8 @@ activate_node_snapshot(PG_FUNCTION_ARGS)
|
||||||
|
|
||||||
List *recreateTablesCommands = RecreateDistributedTablesWithDependenciesCommandList(
|
List *recreateTablesCommands = RecreateDistributedTablesWithDependenciesCommandList(
|
||||||
dummyWorkerNode);
|
dummyWorkerNode);
|
||||||
List *dropSnapshotCommands = MetadataDropCommands();
|
List *dropSnapshotCommands = NodeMetadataDropCommands();
|
||||||
List *createSnapshotCommands = MetadataCreateCommands();
|
List *createSnapshotCommands = NodeMetadataCreateCommands();
|
||||||
List *metadataUpdateCommandList = ResyncMetadataCommandList();
|
List *metadataUpdateCommandList = ResyncMetadataCommandList();
|
||||||
List *activateNodeCommandList = NIL;
|
List *activateNodeCommandList = NIL;
|
||||||
int activateNodeCommandIndex = 0;
|
int activateNodeCommandIndex = 0;
|
||||||
|
|
|
@ -524,7 +524,7 @@ CitusMaintenanceDaemonMain(Datum main_arg)
|
||||||
if (syncMetadata)
|
if (syncMetadata)
|
||||||
{
|
{
|
||||||
metadataSyncBgwHandle =
|
metadataSyncBgwHandle =
|
||||||
SpawnSyncMetadataToNodes(MyDatabaseId, myDbData->userOid);
|
SpawnSyncNodeMetadataToNodes(MyDatabaseId, myDbData->userOid);
|
||||||
}
|
}
|
||||||
|
|
||||||
nextMetadataSyncTime =
|
nextMetadataSyncTime =
|
||||||
|
|
|
@ -33,9 +33,9 @@ extern bool ClusterHasKnownMetadataWorkers(void);
|
||||||
extern char * LocalGroupIdUpdateCommand(int32 groupId);
|
extern char * LocalGroupIdUpdateCommand(int32 groupId);
|
||||||
extern bool ShouldSyncTableMetadata(Oid relationId);
|
extern bool ShouldSyncTableMetadata(Oid relationId);
|
||||||
extern bool ShouldSyncTableMetadataViaCatalog(Oid relationId);
|
extern bool ShouldSyncTableMetadataViaCatalog(Oid relationId);
|
||||||
extern List * MetadataCreateCommands(void);
|
extern List * NodeMetadataCreateCommands(void);
|
||||||
extern List * DistributedObjectMetadataSyncCommandList(void);
|
extern List * DistributedObjectMetadataSyncCommandList(void);
|
||||||
extern List * MetadataDropCommands(void);
|
extern List * NodeMetadataDropCommands(void);
|
||||||
extern char * MarkObjectsDistributedCreateCommand(List *addresses,
|
extern char * MarkObjectsDistributedCreateCommand(List *addresses,
|
||||||
List *distributionArgumentIndexes,
|
List *distributionArgumentIndexes,
|
||||||
List *colocationIds);
|
List *colocationIds);
|
||||||
|
@ -57,8 +57,8 @@ extern char * TruncateTriggerCreateCommand(Oid relationId);
|
||||||
extern void CreateShellTableOnWorkers(Oid relationId);
|
extern void CreateShellTableOnWorkers(Oid relationId);
|
||||||
extern void CreateTableMetadataOnWorkers(Oid relationId);
|
extern void CreateTableMetadataOnWorkers(Oid relationId);
|
||||||
extern List * DetachPartitionCommandList(void);
|
extern List * DetachPartitionCommandList(void);
|
||||||
extern BackgroundWorkerHandle * SpawnSyncMetadataToNodes(Oid database, Oid owner);
|
extern BackgroundWorkerHandle * SpawnSyncNodeMetadataToNodes(Oid database, Oid owner);
|
||||||
extern void SyncMetadataToNodesMain(Datum main_arg);
|
extern void SyncNodeMetadataToNodesMain(Datum main_arg);
|
||||||
extern void SignalMetadataSyncDaemon(Oid database, int sig);
|
extern void SignalMetadataSyncDaemon(Oid database, int sig);
|
||||||
extern bool ShouldInitiateMetadataSync(bool *lockFailure);
|
extern bool ShouldInitiateMetadataSync(bool *lockFailure);
|
||||||
extern List * SequenceDependencyCommandList(Oid relationId);
|
extern List * SequenceDependencyCommandList(Oid relationId);
|
||||||
|
|
Loading…
Reference in New Issue