mirror of https://github.com/citusdata/citus.git
Address comments
parent
a3a2ce448a
commit
f69bf9ff40
|
@ -653,51 +653,6 @@ GetAllViews(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ShouldMarkRelationDistributed is a helper function that
|
|
||||||
* decides whether the input relation should be marked as distributed
|
|
||||||
* during the upgrade.
|
|
||||||
*/
|
|
||||||
bool
|
|
||||||
ShouldMarkRelationDistributed(Oid relationId)
|
|
||||||
{
|
|
||||||
if (!EnableMetadataSync)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Just in case anything goes wrong, we should still be able
|
|
||||||
* to continue to the version upgrade.
|
|
||||||
*/
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ObjectAddress relationAddress = { 0 };
|
|
||||||
ObjectAddressSet(relationAddress, RelationRelationId, relationId);
|
|
||||||
|
|
||||||
bool pgObject = (relationId < FirstNormalObjectId);
|
|
||||||
bool ownedByExtension = IsTableOwnedByExtension(relationId);
|
|
||||||
bool alreadyDistributed = IsObjectDistributed(&relationAddress);
|
|
||||||
bool hasUnsupportedDependency =
|
|
||||||
DeferErrorIfHasUnsupportedDependency(&relationAddress) != NULL;
|
|
||||||
bool hasCircularDependency =
|
|
||||||
DeferErrorIfCircularDependencyExists(&relationAddress) != NULL;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* pgObject: Citus never marks pg objects as distributed
|
|
||||||
* ownedByExtension: let extensions manage its own objects
|
|
||||||
* alreadyDistributed: most likely via earlier versions
|
|
||||||
* hasUnsupportedDependency: Citus doesn't know how to distribute its dependencies
|
|
||||||
* hasCircularDependency: Citus cannot handle circular dependencies
|
|
||||||
*/
|
|
||||||
if (pgObject || ownedByExtension || alreadyDistributed ||
|
|
||||||
hasUnsupportedDependency || hasCircularDependency)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PreprocessAlterExtensionContentsStmt issues a notice. It does not propagate.
|
* PreprocessAlterExtensionContentsStmt issues a notice. It does not propagate.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -29,7 +29,9 @@
|
||||||
#include "citus_version.h"
|
#include "citus_version.h"
|
||||||
#include "commands/extension.h"
|
#include "commands/extension.h"
|
||||||
#include "distributed/colocation_utils.h"
|
#include "distributed/colocation_utils.h"
|
||||||
|
#include "distributed/commands.h"
|
||||||
#include "distributed/commands/utility_hook.h"
|
#include "distributed/commands/utility_hook.h"
|
||||||
|
#include "distributed/metadata/dependency.h"
|
||||||
#include "distributed/metadata/distobject.h"
|
#include "distributed/metadata/distobject.h"
|
||||||
#include "distributed/metadata/pg_dist_object.h"
|
#include "distributed/metadata/pg_dist_object.h"
|
||||||
#include "distributed/metadata_cache.h"
|
#include "distributed/metadata_cache.h"
|
||||||
|
@ -220,6 +222,56 @@ MarkObjectDistributedLocally(const ObjectAddress *distAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ShouldMarkRelationDistributed is a helper function that
|
||||||
|
* decides whether the input relation should be marked as distributed.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
ShouldMarkRelationDistributed(Oid relationId)
|
||||||
|
{
|
||||||
|
if (!EnableMetadataSync)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Just in case anything goes wrong, we should still be able
|
||||||
|
* to continue to the version upgrade.
|
||||||
|
*/
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjectAddress relationAddress = { 0 };
|
||||||
|
ObjectAddressSet(relationAddress, RelationRelationId, relationId);
|
||||||
|
|
||||||
|
/* check if the relation itself is supported or not */
|
||||||
|
if (!SupportedDependencyByCitus(&relationAddress))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool pgObject = (relationId < FirstNormalObjectId);
|
||||||
|
bool ownedByExtension = IsTableOwnedByExtension(relationId);
|
||||||
|
bool alreadyDistributed = IsObjectDistributed(&relationAddress);
|
||||||
|
bool hasUnsupportedDependency =
|
||||||
|
DeferErrorIfHasUnsupportedDependency(&relationAddress) != NULL;
|
||||||
|
bool hasCircularDependency =
|
||||||
|
DeferErrorIfCircularDependencyExists(&relationAddress) != NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* pgObject: Citus never marks pg objects as distributed
|
||||||
|
* ownedByExtension: let extensions manage its own objects
|
||||||
|
* alreadyDistributed: most likely via earlier versions
|
||||||
|
* hasUnsupportedDependency: Citus doesn't know how to distribute its dependencies
|
||||||
|
* hasCircularDependency: Citus cannot handle circular dependencies
|
||||||
|
*/
|
||||||
|
if (pgObject || ownedByExtension || alreadyDistributed ||
|
||||||
|
hasUnsupportedDependency || hasCircularDependency)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CreatePgDistObjectEntryCommand creates command to insert pg_dist_object tuple
|
* CreatePgDistObjectEntryCommand creates command to insert pg_dist_object tuple
|
||||||
* for the given object address.
|
* for the given object address.
|
||||||
|
|
|
@ -98,6 +98,7 @@ static char * SchemaOwnerName(Oid objectId);
|
||||||
static bool HasMetadataWorkers(void);
|
static bool HasMetadataWorkers(void);
|
||||||
static void CreateShellTableOnWorkers(Oid relationId);
|
static void CreateShellTableOnWorkers(Oid relationId);
|
||||||
static void CreateTableMetadataOnWorkers(Oid relationId);
|
static void CreateTableMetadataOnWorkers(Oid relationId);
|
||||||
|
static void CreateDependentViewsOnWorkers(Oid relationId);
|
||||||
static NodeMetadataSyncResult SyncNodeMetadataToNodesOptional(void);
|
static NodeMetadataSyncResult SyncNodeMetadataToNodesOptional(void);
|
||||||
static bool ShouldSyncTableMetadataInternal(bool hashDistributed,
|
static bool ShouldSyncTableMetadataInternal(bool hashDistributed,
|
||||||
bool citusTableWithNoDistKey);
|
bool citusTableWithNoDistKey);
|
||||||
|
@ -303,7 +304,8 @@ SyncNodeMetadataToNode(const char *nodeNameString, int32 nodePort)
|
||||||
* SyncCitusTableMetadata syncs citus table metadata to worker nodes with metadata.
|
* SyncCitusTableMetadata syncs citus table metadata to worker nodes with metadata.
|
||||||
* Our definition of metadata includes the shell table and its inter relations with
|
* Our definition of metadata includes the shell table and its inter relations with
|
||||||
* other shell tables, corresponding pg_dist_object, pg_dist_partiton, pg_dist_shard
|
* other shell tables, corresponding pg_dist_object, pg_dist_partiton, pg_dist_shard
|
||||||
* and pg_dist_shard placement entries.
|
* and pg_dist_shard placement entries. This function also propagates the views that
|
||||||
|
* depend on the given relation, to the metadata workers.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
SyncCitusTableMetadata(Oid relationId)
|
SyncCitusTableMetadata(Oid relationId)
|
||||||
|
@ -327,7 +329,7 @@ SyncCitusTableMetadata(Oid relationId)
|
||||||
* CreateDependentViewsOnWorkers takes a relationId and creates the views that depend on
|
* CreateDependentViewsOnWorkers takes a relationId and creates the views that depend on
|
||||||
* that relation on workers with metadata.
|
* that relation on workers with metadata.
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
CreateDependentViewsOnWorkers(Oid relationId)
|
CreateDependentViewsOnWorkers(Oid relationId)
|
||||||
{
|
{
|
||||||
List *views = GetDependingViews(relationId);
|
List *views = GetDependingViews(relationId);
|
||||||
|
|
|
@ -32,7 +32,6 @@ typedef enum
|
||||||
/* Functions declarations for metadata syncing */
|
/* Functions declarations for metadata syncing */
|
||||||
extern void SyncNodeMetadataToNode(const char *nodeNameString, int32 nodePort);
|
extern void SyncNodeMetadataToNode(const char *nodeNameString, int32 nodePort);
|
||||||
extern void SyncCitusTableMetadata(Oid relationId);
|
extern void SyncCitusTableMetadata(Oid relationId);
|
||||||
extern void CreateDependentViewsOnWorkers(Oid relationId);
|
|
||||||
extern void EnsureSequentialModeMetadataOperations(void);
|
extern void EnsureSequentialModeMetadataOperations(void);
|
||||||
extern bool ClusterHasKnownMetadataWorkers(void);
|
extern bool ClusterHasKnownMetadataWorkers(void);
|
||||||
extern char * LocalGroupIdUpdateCommand(int32 groupId);
|
extern char * LocalGroupIdUpdateCommand(int32 groupId);
|
||||||
|
|
Loading…
Reference in New Issue