rename needsisolatednode to needsseparatenode

tenant-schema-isolation-complete-view
Onur Tirtir 2023-09-29 15:13:04 +03:00
parent a58442d411
commit cc587101ed
43 changed files with 270 additions and 264 deletions

View File

@ -1456,9 +1456,9 @@ InsertMetadataForCitusLocalTable(Oid citusLocalTableId, uint64 shardId,
text *shardMinValue = NULL; text *shardMinValue = NULL;
text *shardMaxValue = NULL; text *shardMaxValue = NULL;
bool needsIsolatedNode = false; bool needsSeparateNode = false;
InsertShardRow(citusLocalTableId, shardId, shardStorageType, InsertShardRow(citusLocalTableId, shardId, shardStorageType,
shardMinValue, shardMaxValue, needsIsolatedNode); shardMinValue, shardMaxValue, needsSeparateNode);
List *nodeList = list_make1(CoordinatorNodeIfAddedAsWorkerOrError()); List *nodeList = list_make1(CoordinatorNodeIfAddedAsWorkerOrError());

View File

@ -134,7 +134,7 @@ static char DecideDistTableReplicationModel(char distributionMethod,
static List * HashSplitPointsForShardList(List *shardList); static List * HashSplitPointsForShardList(List *shardList);
static List * HashSplitPointsForShardCount(int shardCount); static List * HashSplitPointsForShardCount(int shardCount);
static List * WorkerNodesForShardList(List *shardList); static List * WorkerNodesForShardList(List *shardList);
static List * NeedsIsolatedNodeForShardList(List *shardList); static List * NeedsSeparateNodeForShardList(List *shardList);
static List * RoundRobinWorkerNodeList(List *workerNodeList, int listLength); static List * RoundRobinWorkerNodeList(List *workerNodeList, int listLength);
static CitusTableParams DecideCitusTableParams(CitusTableType tableType, static CitusTableParams DecideCitusTableParams(CitusTableType tableType,
DistributedTableParams * DistributedTableParams *
@ -574,7 +574,7 @@ CreateDistributedTableConcurrently(Oid relationId, char *distributionColumnName,
List *workersForPlacementList; List *workersForPlacementList;
List *shardSplitPointsList; List *shardSplitPointsList;
List *needsIsolatedNodeForPlacementList; List *needsSeparateNodeForPlacementList;
if (colocatedTableId != InvalidOid) if (colocatedTableId != InvalidOid)
@ -592,10 +592,10 @@ CreateDistributedTableConcurrently(Oid relationId, char *distributionColumnName,
workersForPlacementList = WorkerNodesForShardList(colocatedShardList); workersForPlacementList = WorkerNodesForShardList(colocatedShardList);
/* /*
* Inherit needsisolatednode from the colocated shards. * Inherit needsseparatenode from the colocated shards.
*/ */
needsIsolatedNodeForPlacementList = needsSeparateNodeForPlacementList =
NeedsIsolatedNodeForShardList(colocatedShardList); NeedsSeparateNodeForShardList(colocatedShardList);
} }
else else
{ {
@ -618,10 +618,10 @@ CreateDistributedTableConcurrently(Oid relationId, char *distributionColumnName,
workersForPlacementList = RoundRobinWorkerNodeList(workerNodeList, shardCount); workersForPlacementList = RoundRobinWorkerNodeList(workerNodeList, shardCount);
/* /*
* For a new colocation group, needsisolatednode is set to false for * For a new colocation group, needsseparatenode is set to false for
* all shards. * all shards.
*/ */
needsIsolatedNodeForPlacementList = GenerateListFromIntElement(false, shardCount); needsSeparateNodeForPlacementList = GenerateListFromIntElement(false, shardCount);
} }
/* /*
@ -660,7 +660,7 @@ CreateDistributedTableConcurrently(Oid relationId, char *distributionColumnName,
shardToSplit->shardId, shardToSplit->shardId,
shardSplitPointsList, shardSplitPointsList,
workersForPlacementList, workersForPlacementList,
needsIsolatedNodeForPlacementList, needsSeparateNodeForPlacementList,
distributionColumnOverrides, distributionColumnOverrides,
sourceColocatedShardIntervalList, sourceColocatedShardIntervalList,
colocationId colocationId
@ -914,22 +914,22 @@ WorkerNodesForShardList(List *shardList)
/* /*
* NeedsIsolatedNodeForShardList returns a list of node booleans reflecting whether * NeedsSeparateNodeForShardList returns a list of node booleans reflecting whether
* each shard in the given list needs an isolated node. * each shard in the given list needs a separate node.
*/ */
static List * static List *
NeedsIsolatedNodeForShardList(List *shardList) NeedsSeparateNodeForShardList(List *shardList)
{ {
List *needsIsolatedNodeList = NIL; List *needsSeparateNodeList = NIL;
ShardInterval *shardInterval = NULL; ShardInterval *shardInterval = NULL;
foreach_ptr(shardInterval, shardList) foreach_ptr(shardInterval, shardList)
{ {
needsIsolatedNodeList = lappend_int(needsIsolatedNodeList, needsSeparateNodeList = lappend_int(needsSeparateNodeList,
shardInterval->needsIsolatedNode); shardInterval->needsSeparateNode);
} }
return needsIsolatedNodeList; return needsSeparateNodeList;
} }

View File

@ -5379,8 +5379,8 @@ DeformedDistShardTupleToShardInterval(Datum *datumArray, bool *isNullArray,
char storageType = DatumGetChar(datumArray[Anum_pg_dist_shard_shardstorage - 1]); char storageType = DatumGetChar(datumArray[Anum_pg_dist_shard_shardstorage - 1]);
Datum minValueTextDatum = datumArray[Anum_pg_dist_shard_shardminvalue - 1]; Datum minValueTextDatum = datumArray[Anum_pg_dist_shard_shardminvalue - 1];
Datum maxValueTextDatum = datumArray[Anum_pg_dist_shard_shardmaxvalue - 1]; Datum maxValueTextDatum = datumArray[Anum_pg_dist_shard_shardmaxvalue - 1];
bool needsIsolatedNode = DatumGetBool( bool needsSeparateNode = DatumGetBool(
datumArray[Anum_pg_dist_shard_needsisolatednode - 1]); datumArray[Anum_pg_dist_shard_needsseparatenode - 1]);
bool minValueNull = isNullArray[Anum_pg_dist_shard_shardminvalue - 1]; bool minValueNull = isNullArray[Anum_pg_dist_shard_shardminvalue - 1];
bool maxValueNull = isNullArray[Anum_pg_dist_shard_shardmaxvalue - 1]; bool maxValueNull = isNullArray[Anum_pg_dist_shard_shardmaxvalue - 1];
@ -5417,7 +5417,7 @@ DeformedDistShardTupleToShardInterval(Datum *datumArray, bool *isNullArray,
shardInterval->minValue = minValue; shardInterval->minValue = minValue;
shardInterval->maxValue = maxValue; shardInterval->maxValue = maxValue;
shardInterval->shardId = shardId; shardInterval->shardId = shardId;
shardInterval->needsIsolatedNode = needsIsolatedNode; shardInterval->needsSeparateNode = needsSeparateNode;
return shardInterval; return shardInterval;
} }

View File

@ -96,7 +96,7 @@ int MetadataSyncTransMode = METADATA_SYNC_TRANSACTIONAL;
static Datum citus_internal_add_shard_metadata_internal(PG_FUNCTION_ARGS, static Datum citus_internal_add_shard_metadata_internal(PG_FUNCTION_ARGS,
bool expectNeedsIsolatedNode); bool expectNeedsSeparateNode);
static void EnsureObjectMetadataIsSane(int distributionArgumentIndex, static void EnsureObjectMetadataIsSane(int distributionArgumentIndex,
int colocationId); int colocationId);
static List * GetFunctionDependenciesForObjects(ObjectAddress *objectAddress); static List * GetFunctionDependenciesForObjects(ObjectAddress *objectAddress);
@ -182,7 +182,7 @@ PG_FUNCTION_INFO_V1(citus_internal_delete_colocation_metadata);
PG_FUNCTION_INFO_V1(citus_internal_add_tenant_schema); PG_FUNCTION_INFO_V1(citus_internal_add_tenant_schema);
PG_FUNCTION_INFO_V1(citus_internal_delete_tenant_schema); PG_FUNCTION_INFO_V1(citus_internal_delete_tenant_schema);
PG_FUNCTION_INFO_V1(citus_internal_update_none_dist_table_metadata); PG_FUNCTION_INFO_V1(citus_internal_update_none_dist_table_metadata);
PG_FUNCTION_INFO_V1(citus_internal_shard_group_set_needsisolatednode); PG_FUNCTION_INFO_V1(citus_internal_shard_group_set_needsseparatenode);
static bool got_SIGTERM = false; static bool got_SIGTERM = false;
@ -1248,7 +1248,7 @@ ShardListInsertCommand(List *shardIntervalList)
StringInfo insertShardCommand = makeStringInfo(); StringInfo insertShardCommand = makeStringInfo();
appendStringInfo(insertShardCommand, appendStringInfo(insertShardCommand,
"WITH shard_data(relationname, shardid, storagetype, " "WITH shard_data(relationname, shardid, storagetype, "
"shardminvalue, shardmaxvalue, needsisolatednode) AS (VALUES "); "shardminvalue, shardmaxvalue, needsseparatenode) AS (VALUES ");
foreach_ptr(shardInterval, shardIntervalList) foreach_ptr(shardInterval, shardIntervalList)
{ {
@ -1286,7 +1286,7 @@ ShardListInsertCommand(List *shardIntervalList)
shardInterval->storageType, shardInterval->storageType,
minHashToken->data, minHashToken->data,
maxHashToken->data, maxHashToken->data,
shardInterval->needsIsolatedNode ? "true" : "false"); shardInterval->needsSeparateNode ? "true" : "false");
if (llast(shardIntervalList) != shardInterval) if (llast(shardIntervalList) != shardInterval)
{ {
@ -1298,7 +1298,7 @@ ShardListInsertCommand(List *shardIntervalList)
appendStringInfo(insertShardCommand, appendStringInfo(insertShardCommand,
"SELECT citus_internal_add_shard_metadata(relationname, shardid, " "SELECT citus_internal_add_shard_metadata(relationname, shardid, "
"storagetype, shardminvalue, shardmaxvalue, needsisolatednode) " "storagetype, shardminvalue, shardmaxvalue, needsseparatenode) "
"FROM shard_data;"); "FROM shard_data;");
/* /*
@ -3227,21 +3227,21 @@ citus_internal_delete_partition_metadata(PG_FUNCTION_ARGS)
Datum Datum
citus_internal_add_shard_metadata(PG_FUNCTION_ARGS) citus_internal_add_shard_metadata(PG_FUNCTION_ARGS)
{ {
bool expectNeedsIsolatedNode = true; bool expectNeedsSeparateNode = true;
return citus_internal_add_shard_metadata_internal(fcinfo, expectNeedsIsolatedNode); return citus_internal_add_shard_metadata_internal(fcinfo, expectNeedsSeparateNode);
} }
/* /*
* citus_internal_add_shard_metadata is an internal UDF to * citus_internal_add_shard_metadata is an internal UDF to
* add a row to pg_dist_shard, but without the needs_isolated_node * add a row to pg_dist_shard, but without the needs_separate_node
* parameter. * parameter.
*/ */
Datum Datum
citus_internal_add_shard_metadata_legacy(PG_FUNCTION_ARGS) citus_internal_add_shard_metadata_legacy(PG_FUNCTION_ARGS)
{ {
bool expectNeedsIsolatedNode = false; bool expectNeedsSeparateNode = false;
return citus_internal_add_shard_metadata_internal(fcinfo, expectNeedsIsolatedNode); return citus_internal_add_shard_metadata_internal(fcinfo, expectNeedsSeparateNode);
} }
@ -3252,7 +3252,7 @@ citus_internal_add_shard_metadata_legacy(PG_FUNCTION_ARGS)
*/ */
static Datum static Datum
citus_internal_add_shard_metadata_internal(PG_FUNCTION_ARGS, citus_internal_add_shard_metadata_internal(PG_FUNCTION_ARGS,
bool expectNeedsIsolatedNode) bool expectNeedsSeparateNode)
{ {
CheckCitusVersion(ERROR); CheckCitusVersion(ERROR);
@ -3277,11 +3277,11 @@ citus_internal_add_shard_metadata_internal(PG_FUNCTION_ARGS,
shardMaxValue = PG_GETARG_TEXT_P(4); shardMaxValue = PG_GETARG_TEXT_P(4);
} }
bool needsIsolatedNode = false; bool needsSeparateNode = false;
if (expectNeedsIsolatedNode) if (expectNeedsSeparateNode)
{ {
PG_ENSURE_ARGNOTNULL(5, "needs isolated node"); PG_ENSURE_ARGNOTNULL(5, "needs separate node");
needsIsolatedNode = PG_GETARG_BOOL(5); needsSeparateNode = PG_GETARG_BOOL(5);
} }
/* only owner of the table (or superuser) is allowed to add the Citus metadata */ /* only owner of the table (or superuser) is allowed to add the Citus metadata */
@ -3305,7 +3305,7 @@ citus_internal_add_shard_metadata_internal(PG_FUNCTION_ARGS,
} }
InsertShardRow(relationId, shardId, storageType, shardMinValue, shardMaxValue, InsertShardRow(relationId, shardId, storageType, shardMinValue, shardMaxValue,
needsIsolatedNode); needsSeparateNode);
PG_RETURN_VOID(); PG_RETURN_VOID();
} }
@ -3936,12 +3936,12 @@ citus_internal_update_none_dist_table_metadata(PG_FUNCTION_ARGS)
/* /*
* citus_internal_shard_group_set_needsisolatednode is an internal UDF to * citus_internal_shard_group_set_needsseparatenode is an internal UDF to
* set needsisolatednode flag for all the shards within the shard group * set needsseparatenode flag for all the shards within the shard group
* that given shard belongs to. * that given shard belongs to.
*/ */
Datum Datum
citus_internal_shard_group_set_needsisolatednode(PG_FUNCTION_ARGS) citus_internal_shard_group_set_needsseparatenode(PG_FUNCTION_ARGS)
{ {
CheckCitusVersion(ERROR); CheckCitusVersion(ERROR);
@ -3963,7 +3963,7 @@ citus_internal_shard_group_set_needsisolatednode(PG_FUNCTION_ARGS)
EnsureCoordinatorInitiatedOperation(); EnsureCoordinatorInitiatedOperation();
} }
ShardGroupSetNeedsIsolatedNode(shardId, enabled); ShardGroupSetNeedsSeparateNode(shardId, enabled);
PG_RETURN_VOID(); PG_RETURN_VOID();
} }
@ -4169,15 +4169,15 @@ UpdateNoneDistTableMetadataCommand(Oid relationId, char replicationModel,
/* /*
* ShardGroupSetNeedsIsolatedNodeCommand returns a command to call * ShardGroupSetNeedsSeparateNodeCommand returns a command to call
* citus_internal_shard_group_set_needsisolatednode(). * citus_internal_shard_group_set_needsseparatenode().
*/ */
char * char *
ShardGroupSetNeedsIsolatedNodeCommand(uint64 shardId, bool enabled) ShardGroupSetNeedsSeparateNodeCommand(uint64 shardId, bool enabled)
{ {
StringInfo command = makeStringInfo(); StringInfo command = makeStringInfo();
appendStringInfo(command, appendStringInfo(command,
"SELECT pg_catalog.citus_internal_shard_group_set_needsisolatednode(%lu, %s)", "SELECT pg_catalog.citus_internal_shard_group_set_needsseparatenode(%lu, %s)",
shardId, enabled ? "true" : "false"); shardId, enabled ? "true" : "false");
return command->data; return command->data;

View File

@ -116,8 +116,8 @@ static HeapTuple CreateDiskSpaceTuple(TupleDesc tupleDesc, uint64 availableBytes
uint64 totalBytes); uint64 totalBytes);
static bool GetLocalDiskSpaceStats(uint64 *availableBytes, uint64 *totalBytes); static bool GetLocalDiskSpaceStats(uint64 *availableBytes, uint64 *totalBytes);
static void citus_shard_property_set_anti_affinity(uint64 shardId, bool enabled); static void citus_shard_property_set_anti_affinity(uint64 shardId, bool enabled);
static void ShardGroupSetNeedsIsolatedNodeGlobally(uint64 shardId, bool enabled); static void ShardGroupSetNeedsSeparateNodeGlobally(uint64 shardId, bool enabled);
static void ShardSetNeedsIsolatedNode(uint64 shardId, bool enabled); static void ShardSetNeedsSeparateNode(uint64 shardId, bool enabled);
static BackgroundTask * DeformBackgroundTaskHeapTuple(TupleDesc tupleDescriptor, static BackgroundTask * DeformBackgroundTaskHeapTuple(TupleDesc tupleDescriptor,
HeapTuple taskTuple); HeapTuple taskTuple);
@ -417,32 +417,32 @@ citus_shard_property_set_anti_affinity(uint64 shardId, bool enabled)
"distributed tables"))); "distributed tables")));
} }
ShardGroupSetNeedsIsolatedNodeGlobally(shardId, enabled); ShardGroupSetNeedsSeparateNodeGlobally(shardId, enabled);
} }
/* /*
* ShardGroupSetNeedsIsolatedNodeGlobally calls ShardGroupSetNeedsIsolatedNode * ShardGroupSetNeedsSeparateNodeGlobally calls ShardGroupSetNeedsSeparateNode
* on all nodes. * on all nodes.
*/ */
static void static void
ShardGroupSetNeedsIsolatedNodeGlobally(uint64 shardId, bool enabled) ShardGroupSetNeedsSeparateNodeGlobally(uint64 shardId, bool enabled)
{ {
ShardGroupSetNeedsIsolatedNode(shardId, enabled); ShardGroupSetNeedsSeparateNode(shardId, enabled);
char *metadataCommand = char *metadataCommand =
ShardGroupSetNeedsIsolatedNodeCommand(shardId, enabled); ShardGroupSetNeedsSeparateNodeCommand(shardId, enabled);
SendCommandToWorkersWithMetadata(metadataCommand); SendCommandToWorkersWithMetadata(metadataCommand);
} }
/* /*
* ShardGroupSetNeedsIsolatedNode sets the needsisolatednode flag to desired * ShardGroupSetNeedsSeparateNode sets the needsseparatenode flag to desired
* value for all the shards within the shard group that given shard belongs * value for all the shards within the shard group that given shard belongs
* to. * to.
*/ */
void void
ShardGroupSetNeedsIsolatedNode(uint64 shardId, bool enabled) ShardGroupSetNeedsSeparateNode(uint64 shardId, bool enabled)
{ {
ShardInterval *shardInterval = LoadShardInterval(shardId); ShardInterval *shardInterval = LoadShardInterval(shardId);
List *colocatedShardIntervalList = ColocatedShardIntervalList(shardInterval); List *colocatedShardIntervalList = ColocatedShardIntervalList(shardInterval);
@ -450,18 +450,18 @@ ShardGroupSetNeedsIsolatedNode(uint64 shardId, bool enabled)
ShardInterval *colocatedShardInterval = NULL; ShardInterval *colocatedShardInterval = NULL;
foreach_ptr(colocatedShardInterval, colocatedShardIntervalList) foreach_ptr(colocatedShardInterval, colocatedShardIntervalList)
{ {
ShardSetNeedsIsolatedNode(colocatedShardInterval->shardId, ShardSetNeedsSeparateNode(colocatedShardInterval->shardId,
enabled); enabled);
} }
} }
/* /*
* ShardSetNeedsIsolatedNode sets the needsisolatednode flag to desired * ShardSetNeedsSeparateNode sets the needsseparatenode flag to desired
* value for the given shard. * value for the given shard.
*/ */
static void static void
ShardSetNeedsIsolatedNode(uint64 shardId, bool enabled) ShardSetNeedsSeparateNode(uint64 shardId, bool enabled)
{ {
Relation pgDistShard = table_open(DistShardRelationId(), RowExclusiveLock); Relation pgDistShard = table_open(DistShardRelationId(), RowExclusiveLock);
@ -492,9 +492,9 @@ ShardSetNeedsIsolatedNode(uint64 shardId, bool enabled)
memset(isnull, false, sizeof(isnull)); memset(isnull, false, sizeof(isnull));
memset(replace, false, sizeof(replace)); memset(replace, false, sizeof(replace));
values[Anum_pg_dist_shard_needsisolatednode - 1] = BoolGetDatum(enabled); values[Anum_pg_dist_shard_needsseparatenode - 1] = BoolGetDatum(enabled);
isnull[Anum_pg_dist_shard_needsisolatednode - 1] = false; isnull[Anum_pg_dist_shard_needsseparatenode - 1] = false;
replace[Anum_pg_dist_shard_needsisolatednode - 1] = true; replace[Anum_pg_dist_shard_needsseparatenode - 1] = true;
TupleDesc tupleDescriptor = RelationGetDescr(pgDistShard); TupleDesc tupleDescriptor = RelationGetDescr(pgDistShard);
heapTuple = heap_modify_tuple(heapTuple, tupleDescriptor, values, isnull, replace); heapTuple = heap_modify_tuple(heapTuple, tupleDescriptor, values, isnull, replace);
@ -1453,7 +1453,7 @@ CopyShardInterval(ShardInterval *srcInterval)
destInterval->maxValueExists = srcInterval->maxValueExists; destInterval->maxValueExists = srcInterval->maxValueExists;
destInterval->shardId = srcInterval->shardId; destInterval->shardId = srcInterval->shardId;
destInterval->shardIndex = srcInterval->shardIndex; destInterval->shardIndex = srcInterval->shardIndex;
destInterval->needsIsolatedNode = srcInterval->needsIsolatedNode; destInterval->needsSeparateNode = srcInterval->needsSeparateNode;
destInterval->minValue = 0; destInterval->minValue = 0;
if (destInterval->minValueExists) if (destInterval->minValueExists)
@ -1502,15 +1502,15 @@ ShardLength(uint64 shardId)
/* /*
* NodeGroupGetIsolatedShardPlacementGroup returns the shard placement group * NodeGroupGetSeparatedShardPlacementGroup returns the shard placement group
* that given node group is used to isolate, if any. Returns NULL if this * that given node group is used to separate from others. Returns NULL if this
* node is not used to a shard placement group. * node is not used to separate a shard placement group.
*/ */
ShardPlacementGroup * ShardPlacementGroup *
NodeGroupGetIsolatedShardPlacementGroup(int32 groupId) NodeGroupGetSeparatedShardPlacementGroup(int32 groupId)
{ {
ShardPlacementGroup *nodeShardPlacementGroup = NULL; ShardPlacementGroup *nodeShardPlacementGroup = NULL;
bool shardPlacementGroupNeedsIsolatedNode = false; bool shardPlacementGroupNeedsSeparateNode = false;
bool indexOK = false; bool indexOK = false;
int scanKeyCount = 1; int scanKeyCount = 1;
@ -1555,7 +1555,7 @@ NodeGroupGetIsolatedShardPlacementGroup(int32 groupId)
} }
nodeShardPlacementGroup = shardPlacementGroup; nodeShardPlacementGroup = shardPlacementGroup;
shardPlacementGroupNeedsIsolatedNode = shardInterval->needsIsolatedNode; shardPlacementGroupNeedsSeparateNode = shardInterval->needsSeparateNode;
heapTuple = systable_getnext(scanDescriptor); heapTuple = systable_getnext(scanDescriptor);
} }
@ -1563,7 +1563,7 @@ NodeGroupGetIsolatedShardPlacementGroup(int32 groupId)
systable_endscan(scanDescriptor); systable_endscan(scanDescriptor);
table_close(pgDistPlacement, NoLock); table_close(pgDistPlacement, NoLock);
if (!shardPlacementGroupNeedsIsolatedNode) if (!shardPlacementGroupNeedsSeparateNode)
{ {
return NULL; return NULL;
} }
@ -2011,7 +2011,7 @@ IsDummyPlacement(ShardPlacement *taskPlacement)
void void
InsertShardRow(Oid relationId, uint64 shardId, char storageType, InsertShardRow(Oid relationId, uint64 shardId, char storageType,
text *shardMinValue, text *shardMaxValue, text *shardMinValue, text *shardMaxValue,
bool needsIsolatedNode) bool needsSeparateNode)
{ {
Datum values[Natts_pg_dist_shard]; Datum values[Natts_pg_dist_shard];
bool isNulls[Natts_pg_dist_shard]; bool isNulls[Natts_pg_dist_shard];
@ -2023,7 +2023,7 @@ InsertShardRow(Oid relationId, uint64 shardId, char storageType,
values[Anum_pg_dist_shard_logicalrelid - 1] = ObjectIdGetDatum(relationId); values[Anum_pg_dist_shard_logicalrelid - 1] = ObjectIdGetDatum(relationId);
values[Anum_pg_dist_shard_shardid - 1] = Int64GetDatum(shardId); values[Anum_pg_dist_shard_shardid - 1] = Int64GetDatum(shardId);
values[Anum_pg_dist_shard_shardstorage - 1] = CharGetDatum(storageType); values[Anum_pg_dist_shard_shardstorage - 1] = CharGetDatum(storageType);
values[Anum_pg_dist_shard_needsisolatednode - 1] = BoolGetDatum(needsIsolatedNode); values[Anum_pg_dist_shard_needsseparatenode - 1] = BoolGetDatum(needsSeparateNode);
/* dropped shardalias column must also be set; it is still part of the tuple */ /* dropped shardalias column must also be set; it is still part of the tuple */
isNulls[Anum_pg_dist_shard_shardalias_DROPPED - 1] = true; isNulls[Anum_pg_dist_shard_shardalias_DROPPED - 1] = true;

View File

@ -54,8 +54,8 @@ citus_split_shard_by_split_points(PG_FUNCTION_ARGS)
Oid shardTransferModeOid = PG_GETARG_OID(3); Oid shardTransferModeOid = PG_GETARG_OID(3);
SplitMode shardSplitMode = LookupSplitMode(shardTransferModeOid); SplitMode shardSplitMode = LookupSplitMode(shardTransferModeOid);
/* we don't inherit needsisolatednode for new shards */ /* we don't inherit needsseparatenode for new shards */
List *needsIsolatedNodeForPlacementList = List *needsSeparateNodeForPlacementList =
GenerateListFromIntElement(false, list_length(nodeIdsForPlacementList)); GenerateListFromIntElement(false, list_length(nodeIdsForPlacementList));
DistributionColumnMap *distributionColumnOverrides = NULL; DistributionColumnMap *distributionColumnOverrides = NULL;
@ -66,7 +66,7 @@ citus_split_shard_by_split_points(PG_FUNCTION_ARGS)
shardIdToSplit, shardIdToSplit,
shardSplitPointsList, shardSplitPointsList,
nodeIdsForPlacementList, nodeIdsForPlacementList,
needsIsolatedNodeForPlacementList, needsSeparateNodeForPlacementList,
distributionColumnOverrides, distributionColumnOverrides,
sourceColocatedShardIntervalList, sourceColocatedShardIntervalList,
INVALID_COLOCATION_ID); INVALID_COLOCATION_ID);

View File

@ -190,9 +190,9 @@ CreateShardsWithRoundRobinPolicy(Oid distributedTableId, int32 shardCount,
text *minHashTokenText = IntegerToText(shardMinHashToken); text *minHashTokenText = IntegerToText(shardMinHashToken);
text *maxHashTokenText = IntegerToText(shardMaxHashToken); text *maxHashTokenText = IntegerToText(shardMaxHashToken);
bool needsIsolatedNode = false; bool needsSeparateNode = false;
InsertShardRow(distributedTableId, *shardIdPtr, shardStorageType, InsertShardRow(distributedTableId, *shardIdPtr, shardStorageType,
minHashTokenText, maxHashTokenText, needsIsolatedNode); minHashTokenText, maxHashTokenText, needsSeparateNode);
InsertShardPlacementRows(distributedTableId, InsertShardPlacementRows(distributedTableId,
*shardIdPtr, *shardIdPtr,
@ -290,9 +290,9 @@ CreateColocatedShards(Oid targetRelationId, Oid sourceRelationId, bool
sourceShardId); sourceShardId);
/* inherit from the colocated shard */ /* inherit from the colocated shard */
bool needsIsolatedNode = sourceShardInterval->needsIsolatedNode; bool needsSeparateNode = sourceShardInterval->needsSeparateNode;
InsertShardRow(targetRelationId, *newShardIdPtr, targetShardStorageType, InsertShardRow(targetRelationId, *newShardIdPtr, targetShardStorageType,
shardMinValueText, shardMaxValueText, needsIsolatedNode); shardMinValueText, shardMaxValueText, needsSeparateNode);
ShardPlacement *sourcePlacement = NULL; ShardPlacement *sourcePlacement = NULL;
foreach_ptr(sourcePlacement, sourceShardPlacementList) foreach_ptr(sourcePlacement, sourceShardPlacementList)
@ -374,9 +374,9 @@ CreateReferenceTableShard(Oid distributedTableId)
/* get the next shard id */ /* get the next shard id */
uint64 shardId = GetNextShardId(); uint64 shardId = GetNextShardId();
bool needsIsolatedNode = false; bool needsSeparateNode = false;
InsertShardRow(distributedTableId, shardId, shardStorageType, shardMinValue, InsertShardRow(distributedTableId, shardId, shardStorageType, shardMinValue,
shardMaxValue, needsIsolatedNode); shardMaxValue, needsSeparateNode);
InsertShardPlacementRows(distributedTableId, InsertShardPlacementRows(distributedTableId,
shardId, shardId,
@ -431,9 +431,9 @@ CreateSingleShardTableShardWithRoundRobinPolicy(Oid relationId, uint32 colocatio
text *minHashTokenText = NULL; text *minHashTokenText = NULL;
text *maxHashTokenText = NULL; text *maxHashTokenText = NULL;
uint64 shardId = GetNextShardId(); uint64 shardId = GetNextShardId();
bool needsIsolatedNode = false; bool needsSeparateNode = false;
InsertShardRow(relationId, shardId, shardStorageType, InsertShardRow(relationId, shardId, shardStorageType,
minHashTokenText, maxHashTokenText, needsIsolatedNode); minHashTokenText, maxHashTokenText, needsSeparateNode);
int replicationFactor = 1; int replicationFactor = 1;
InsertShardPlacementRows(relationId, InsertShardPlacementRows(relationId,

View File

@ -166,8 +166,8 @@ isolate_tenant_to_new_shard(PG_FUNCTION_ARGS)
nodeIdsForPlacementList = lappend_int(nodeIdsForPlacementList, sourceNodeId); nodeIdsForPlacementList = lappend_int(nodeIdsForPlacementList, sourceNodeId);
} }
/* we don't inherit needsisolatednode for new shards */ /* we don't inherit needsseparatenode for new shards */
List *needsIsolatedNodeForPlacementList = List *needsSeparateNodeForPlacementList =
GenerateListFromIntElement(false, list_length(nodeIdsForPlacementList)); GenerateListFromIntElement(false, list_length(nodeIdsForPlacementList));
DistributionColumnMap *distributionColumnOverrides = NULL; DistributionColumnMap *distributionColumnOverrides = NULL;
@ -178,7 +178,7 @@ isolate_tenant_to_new_shard(PG_FUNCTION_ARGS)
sourceShard->shardId, sourceShard->shardId,
shardSplitPointsList, shardSplitPointsList,
nodeIdsForPlacementList, nodeIdsForPlacementList,
needsIsolatedNodeForPlacementList, needsSeparateNodeForPlacementList,
distributionColumnOverrides, distributionColumnOverrides,
sourceColocatedShardIntervalList, sourceColocatedShardIntervalList,
INVALID_COLOCATION_ID); INVALID_COLOCATION_ID);

View File

@ -1,8 +1,8 @@
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* *
* rebalancer_placement_isolation.c * rebalancer_placement_isolation.c
* Routines to determine which worker node should be used to isolate * Routines to determine which worker node should be used to separate
* a colocated set of shard placements that needs isolation. * a colocated set of shard placements that need separate nodes.
* *
* Copyright (c) Citus Data, Inc. * Copyright (c) Citus Data, Inc.
* *
@ -32,7 +32,8 @@ struct RebalancerPlacementIsolationContext
/* /*
* Entry of the hash table that maps each primary worker node to a shard * Entry of the hash table that maps each primary worker node to a shard
* placement group that is determined to be isolated on that node. * placement group that is determined to be separated from other shards in
* the cluster via that node.
*/ */
typedef struct typedef struct
{ {
@ -48,20 +49,21 @@ typedef struct
bool shouldHaveShards; bool shouldHaveShards;
/* /*
* Whether given node is allowed to isolate any shard placement groups. * Whether given node is allowed to separate any shard placement groups.
* *
* This is set only if we're draining a single node because otherwise * This is set only if we're draining a single node because otherwise
* we have the control to isolate shard placement groups on any node. * we have the control to separate shard placement groups on any node.
* *
* However if we're draining a single node, we cannot isolate shard * However if we're draining a single node, we cannot separate shard
* placement groups on the node that already has some placements because * placement groups on the node that already has some placements because
* we cannot move the existing placements from a node that we're not * we cannot move the existing placements from a node that we're not
* draining to another node when we're draining a single node. * draining to another node when we're draining a single node.
*/ */
bool allowedToIsolateAnyPlacementGroup; bool allowedToSeparateAnyPlacementGroup;
/* /*
* Shard placement group that is assigned to this node to be isolated. * Shard placement group that is assigned to this node to be separated
* from others in the cluster.
* *
* NULL if no shard placement group is assigned yet. * NULL if no shard placement group is assigned yet.
*/ */
@ -93,8 +95,8 @@ static int WorkerNodeListGetNodeWithGroupId(List *workerNodeList, int32 nodeGrou
/* /*
* PrepareRebalancerPlacementIsolationContext creates RebalancerPlacementIsolationContext * PrepareRebalancerPlacementIsolationContext creates RebalancerPlacementIsolationContext
* that keeps track of which worker nodes are used to isolate which shard placement groups * that keeps track of which worker nodes are used to separate which shard placement groups
* that need an isolated node. * that need separate nodes.
*/ */
RebalancerPlacementIsolationContext * RebalancerPlacementIsolationContext *
PrepareRebalancerPlacementIsolationContext(List *activeWorkerNodeList, PrepareRebalancerPlacementIsolationContext(List *activeWorkerNodeList,
@ -151,25 +153,26 @@ NodePlacementGroupHashInit(HTAB *nodePlacementGroupHash, List *workerNodeList,
} }
nodePlacementGroupHashEntry->shouldHaveShards = shouldHaveShards; nodePlacementGroupHashEntry->shouldHaveShards = shouldHaveShards;
nodePlacementGroupHashEntry->allowedToIsolateAnyPlacementGroup = shouldHaveShards; nodePlacementGroupHashEntry->allowedToSeparateAnyPlacementGroup =
shouldHaveShards;
nodePlacementGroupHashEntry->assignedPlacementGroup = NULL; nodePlacementGroupHashEntry->assignedPlacementGroup = NULL;
/* /*
* For the rest of the comment, assume that: * For the rest of the comment, assume that:
* Node D: the node we're draining * Node D: the node we're draining
* Node I: a node that is not D and that has a shard placement group * Node I: a node that is not D and that has a shard placement group
* that needs an isolated node * that needs a separate node
* Node R: a node that is not D and that has some regular shard * Node R: a node that is not D and that has some regular shard
* placements * placements
* *
* If we're draining a single node, then we don't know whether other * If we're draining a single node, then we don't know whether other
* nodes have any regular shard placements or any that need an isolated * nodes have any regular shard placements or any that need a separate
* node because in that case GetRebalanceSteps() would provide a list of * node because in that case GetRebalanceSteps() would provide a list of
* shard placements that are stored on D, not a list that contains all * shard placements that are stored on D, not a list that contains all
* the placements accross the cluster (because we want to limit node * the placements accross the cluster (because we want to limit node
* draining to that node in that case). Note that when all shard * draining to that node in that case). Note that when all shard
* placements in the cluster are provided, NodePlacementGroupHashAssignNodes() * placements in the cluster are provided, NodePlacementGroupHashAssignNodes()
* would already be aware of which node is used to isolate which shard * would already be aware of which node is used to separate which shard
* placement group or which node is used to store some regular shard * placement group or which node is used to store some regular shard
* placements. That is why we skip below code if we're not draining a * placements. That is why we skip below code if we're not draining a
* single node. It's not only inefficient to run below code when we're * single node. It's not only inefficient to run below code when we're
@ -181,9 +184,9 @@ NodePlacementGroupHashInit(HTAB *nodePlacementGroupHash, List *workerNodeList,
* *
* Below we find out the assigned placement groups for nodes of type * Below we find out the assigned placement groups for nodes of type
* I because we want to avoid from moving the placements (if any) from * I because we want to avoid from moving the placements (if any) from
* node D to node I. We also set allowedToIsolateAnyPlacementGroup to * node D to node I. We also set allowedToSeparateAnyPlacementGroup to
* false for the nodes that already have some shard placements because * false for the nodes that already have some shard placements because
* we want to avoid from moving the placements that need an isolated node * we want to avoid from moving the placements that need a separate node
* (if any) from node D to node R. * (if any) from node D to node R.
*/ */
if (!(shouldHaveShards && drainSingleNode)) if (!(shouldHaveShards && drainSingleNode))
@ -191,17 +194,17 @@ NodePlacementGroupHashInit(HTAB *nodePlacementGroupHash, List *workerNodeList,
continue; continue;
} }
ShardPlacementGroup *isolatedShardPlacementGroup = ShardPlacementGroup *separatedShardPlacementGroup =
NodeGroupGetIsolatedShardPlacementGroup( NodeGroupGetSeparatedShardPlacementGroup(
nodePlacementGroupHashEntry->nodeGroupId); nodePlacementGroupHashEntry->nodeGroupId);
if (isolatedShardPlacementGroup) if (separatedShardPlacementGroup)
{ {
nodePlacementGroupHashEntry->assignedPlacementGroup = nodePlacementGroupHashEntry->assignedPlacementGroup =
isolatedShardPlacementGroup; separatedShardPlacementGroup;
} }
else else
{ {
nodePlacementGroupHashEntry->allowedToIsolateAnyPlacementGroup = nodePlacementGroupHashEntry->allowedToSeparateAnyPlacementGroup =
!NodeGroupHasShardPlacements(nodePlacementGroupHashEntry->nodeGroupId); !NodeGroupHasShardPlacements(nodePlacementGroupHashEntry->nodeGroupId);
} }
} }
@ -210,7 +213,7 @@ NodePlacementGroupHashInit(HTAB *nodePlacementGroupHash, List *workerNodeList,
/* /*
* NodePlacementGroupHashAssignNodes assigns all active shard placements in * NodePlacementGroupHashAssignNodes assigns all active shard placements in
* the cluster that need to be isolated to individual worker nodes. * the cluster that need separate nodes to individual worker nodes.
*/ */
static void static void
NodePlacementGroupHashAssignNodes(HTAB *nodePlacementGroupHash, NodePlacementGroupHashAssignNodes(HTAB *nodePlacementGroupHash,
@ -228,7 +231,7 @@ NodePlacementGroupHashAssignNodes(HTAB *nodePlacementGroupHash,
foreach_ptr(shardPlacement, shardPlacementList) foreach_ptr(shardPlacement, shardPlacementList)
{ {
ShardInterval *shardInterval = LoadShardInterval(shardPlacement->shardId); ShardInterval *shardInterval = LoadShardInterval(shardPlacement->shardId);
if (!shardInterval->needsIsolatedNode) if (!shardInterval->needsSeparateNode)
{ {
continue; continue;
} }
@ -259,8 +262,8 @@ NodePlacementGroupHashAssignNodes(HTAB *nodePlacementGroupHash,
ShardPlacement *unassignedShardPlacement = NULL; ShardPlacement *unassignedShardPlacement = NULL;
foreach_ptr(unassignedShardPlacement, unassignedShardPlacementList) foreach_ptr(unassignedShardPlacement, unassignedShardPlacementList)
{ {
bool isolated = false; bool separated = false;
while (!isolated && availableNodeIdx < list_length(availableWorkerList)) while (!separated && availableNodeIdx < list_length(availableWorkerList))
{ {
WorkerNode *availableWorkerNode = WorkerNode *availableWorkerNode =
(WorkerNode *) list_nth(availableWorkerList, availableNodeIdx); (WorkerNode *) list_nth(availableWorkerList, availableNodeIdx);
@ -270,15 +273,15 @@ NodePlacementGroupHashAssignNodes(HTAB *nodePlacementGroupHash,
availableWorkerNode->groupId, availableWorkerNode->groupId,
unassignedShardPlacement)) unassignedShardPlacement))
{ {
isolated = true; separated = true;
break; break;
} }
} }
if (!isolated) if (!separated)
{ {
ereport(WARNING, (errmsg("could not isolate all shard placements " ereport(WARNING, (errmsg("could not separate all shard placements "
"that need an isolated node"))); "that need a separate node")));
return; return;
} }
} }
@ -317,7 +320,7 @@ NodePlacementGroupHashAssignNode(HTAB *nodePlacementGroupHash,
return false; return false;
} }
if (!nodePlacementGroupHashEntry->allowedToIsolateAnyPlacementGroup) if (!nodePlacementGroupHashEntry->allowedToSeparateAnyPlacementGroup)
{ {
return false; return false;
} }
@ -351,10 +354,10 @@ RebalancerPlacementIsolationContextPlacementIsAllowedOnWorker(
workerNode->groupId); workerNode->groupId);
ShardInterval *shardInterval = LoadShardInterval(shardId); ShardInterval *shardInterval = LoadShardInterval(shardId);
if (!shardInterval->needsIsolatedNode) if (!shardInterval->needsSeparateNode)
{ {
/* /*
* It doesn't need an isolated node, but is the node used to isolate * It doesn't need a separate node, but is the node used to separate
* a shard placement group? If so, we cannot store it on this node. * a shard placement group? If so, we cannot store it on this node.
*/ */
return nodePlacementGroupHashEntry->shouldHaveShards && return nodePlacementGroupHashEntry->shouldHaveShards &&
@ -362,8 +365,8 @@ RebalancerPlacementIsolationContextPlacementIsAllowedOnWorker(
} }
/* /*
* Given shard placement needs an isolated node. * Given shard placement needs a separate node.
* Check if given worker node is the one that is assigned to isolate it. * Check if given worker node is the one that is assigned to separate it.
*/ */
ShardPlacementGroup *placementGroup = ShardPlacementGroup *placementGroup =
GetShardPlacementGroupForPlacement(shardId, placementId); GetShardPlacementGroupForPlacement(shardId, placementId);

View File

@ -94,24 +94,24 @@ static void CreateObjectOnPlacement(List *objectCreationCommandList,
WorkerNode *workerNode); WorkerNode *workerNode);
static List * CreateSplitIntervalsForShardGroup(List *sourceColocatedShardList, static List * CreateSplitIntervalsForShardGroup(List *sourceColocatedShardList,
List *splitPointsForShard, List *splitPointsForShard,
List *needsIsolatedNodeForShardList); List *needsSeparateNodeForShardList);
static void CreateSplitIntervalsForShard(ShardInterval *sourceShard, static void CreateSplitIntervalsForShard(ShardInterval *sourceShard,
List *splitPointsForShard, List *splitPointsForShard,
List *needsIsolatedNodeForShardList, List *needsSeparateNodeForShardList,
List **shardSplitChildrenIntervalList); List **shardSplitChildrenIntervalList);
static void BlockingShardSplit(SplitOperation splitOperation, static void BlockingShardSplit(SplitOperation splitOperation,
uint64 splitWorkflowId, uint64 splitWorkflowId,
List *sourceColocatedShardIntervalList, List *sourceColocatedShardIntervalList,
List *shardSplitPointsList, List *shardSplitPointsList,
List *workersForPlacementList, List *workersForPlacementList,
List *needsIsolatedNodeForShardList, List *needsSeparateNodeForShardList,
DistributionColumnMap *distributionColumnOverrides); DistributionColumnMap *distributionColumnOverrides);
static void NonBlockingShardSplit(SplitOperation splitOperation, static void NonBlockingShardSplit(SplitOperation splitOperation,
uint64 splitWorkflowId, uint64 splitWorkflowId,
List *sourceColocatedShardIntervalList, List *sourceColocatedShardIntervalList,
List *shardSplitPointsList, List *shardSplitPointsList,
List *workersForPlacementList, List *workersForPlacementList,
List *needsIsolatedNodeForShardList, List *needsSeparateNodeForShardList,
DistributionColumnMap *distributionColumnOverrides, DistributionColumnMap *distributionColumnOverrides,
uint32 targetColocationId); uint32 targetColocationId);
static void DoSplitCopy(WorkerNode *sourceShardNode, static void DoSplitCopy(WorkerNode *sourceShardNode,
@ -429,7 +429,7 @@ GetWorkerNodesFromWorkerIds(List *nodeIdsForPlacementList)
* 'shardInterval' : Source shard interval to be split. * 'shardInterval' : Source shard interval to be split.
* 'shardSplitPointsList' : Split Points list for the source 'shardInterval'. * 'shardSplitPointsList' : Split Points list for the source 'shardInterval'.
* 'nodeIdsForPlacementList' : Placement list corresponding to split children. * 'nodeIdsForPlacementList' : Placement list corresponding to split children.
* 'needsIsolatedNodeForShardList' : Whether each split children needs an isolated node. * 'needsSeparateNodeForShardList' : Whether each split children needs a separate node.
* 'distributionColumnOverrides' : Maps relation IDs to distribution columns. * 'distributionColumnOverrides' : Maps relation IDs to distribution columns.
* If not specified, the distribution column is read * If not specified, the distribution column is read
* from the metadata. * from the metadata.
@ -444,7 +444,7 @@ SplitShard(SplitMode splitMode,
uint64 shardIdToSplit, uint64 shardIdToSplit,
List *shardSplitPointsList, List *shardSplitPointsList,
List *nodeIdsForPlacementList, List *nodeIdsForPlacementList,
List *needsIsolatedNodeForShardList, List *needsSeparateNodeForShardList,
DistributionColumnMap *distributionColumnOverrides, DistributionColumnMap *distributionColumnOverrides,
List *colocatedShardIntervalList, List *colocatedShardIntervalList,
uint32 targetColocationId) uint32 targetColocationId)
@ -518,7 +518,7 @@ SplitShard(SplitMode splitMode,
sourceColocatedShardIntervalList, sourceColocatedShardIntervalList,
shardSplitPointsList, shardSplitPointsList,
workersForPlacementList, workersForPlacementList,
needsIsolatedNodeForShardList, needsSeparateNodeForShardList,
distributionColumnOverrides); distributionColumnOverrides);
} }
else else
@ -531,7 +531,7 @@ SplitShard(SplitMode splitMode,
sourceColocatedShardIntervalList, sourceColocatedShardIntervalList,
shardSplitPointsList, shardSplitPointsList,
workersForPlacementList, workersForPlacementList,
needsIsolatedNodeForShardList, needsSeparateNodeForShardList,
distributionColumnOverrides, distributionColumnOverrides,
targetColocationId); targetColocationId);
@ -553,7 +553,7 @@ SplitShard(SplitMode splitMode,
* sourceColocatedShardIntervalList : Source shard group to be split. * sourceColocatedShardIntervalList : Source shard group to be split.
* shardSplitPointsList : Split Points list for the source 'shardInterval'. * shardSplitPointsList : Split Points list for the source 'shardInterval'.
* workersForPlacementList : Placement list corresponding to split children. * workersForPlacementList : Placement list corresponding to split children.
* needsIsolatedNodeForShardList : Whether each split children needs an isolated node. * needsSeparateNodeForShardList : Whether each split children needs a separate node.
*/ */
static void static void
BlockingShardSplit(SplitOperation splitOperation, BlockingShardSplit(SplitOperation splitOperation,
@ -561,7 +561,7 @@ BlockingShardSplit(SplitOperation splitOperation,
List *sourceColocatedShardIntervalList, List *sourceColocatedShardIntervalList,
List *shardSplitPointsList, List *shardSplitPointsList,
List *workersForPlacementList, List *workersForPlacementList,
List *needsIsolatedNodeForShardList, List *needsSeparateNodeForShardList,
DistributionColumnMap *distributionColumnOverrides) DistributionColumnMap *distributionColumnOverrides)
{ {
const char *operationName = SplitOperationAPIName[splitOperation]; const char *operationName = SplitOperationAPIName[splitOperation];
@ -572,7 +572,7 @@ BlockingShardSplit(SplitOperation splitOperation,
List *shardGroupSplitIntervalListList = CreateSplitIntervalsForShardGroup( List *shardGroupSplitIntervalListList = CreateSplitIntervalsForShardGroup(
sourceColocatedShardIntervalList, sourceColocatedShardIntervalList,
shardSplitPointsList, shardSplitPointsList,
needsIsolatedNodeForShardList); needsSeparateNodeForShardList);
/* Only single placement allowed (already validated RelationReplicationFactor = 1) */ /* Only single placement allowed (already validated RelationReplicationFactor = 1) */
ShardInterval *firstShard = linitial(sourceColocatedShardIntervalList); ShardInterval *firstShard = linitial(sourceColocatedShardIntervalList);
@ -1030,12 +1030,12 @@ CreateObjectOnPlacement(List *objectCreationCommandList,
* [ S1_1(-2147483648, 0), S1_2(1, 2147483647) ], // Split Interval List for S1. * [ S1_1(-2147483648, 0), S1_2(1, 2147483647) ], // Split Interval List for S1.
* [ S2_1(-2147483648, 0), S2_2(1, 2147483647) ] // Split Interval List for S2. * [ S2_1(-2147483648, 0), S2_2(1, 2147483647) ] // Split Interval List for S2.
* ] * ]
* 'needsIsolatedNodeForShardList': Whether each split children needs an isolated node * 'needsSeparateNodeForShardList': Whether each split children needs a separate node
*/ */
static List * static List *
CreateSplitIntervalsForShardGroup(List *sourceColocatedShardIntervalList, CreateSplitIntervalsForShardGroup(List *sourceColocatedShardIntervalList,
List *splitPointsForShard, List *splitPointsForShard,
List *needsIsolatedNodeForShardList) List *needsSeparateNodeForShardList)
{ {
List *shardGroupSplitIntervalListList = NIL; List *shardGroupSplitIntervalListList = NIL;
@ -1044,7 +1044,7 @@ CreateSplitIntervalsForShardGroup(List *sourceColocatedShardIntervalList,
{ {
List *shardSplitIntervalList = NIL; List *shardSplitIntervalList = NIL;
CreateSplitIntervalsForShard(shardToSplitInterval, splitPointsForShard, CreateSplitIntervalsForShard(shardToSplitInterval, splitPointsForShard,
needsIsolatedNodeForShardList, needsSeparateNodeForShardList,
&shardSplitIntervalList); &shardSplitIntervalList);
shardGroupSplitIntervalListList = lappend(shardGroupSplitIntervalListList, shardGroupSplitIntervalListList = lappend(shardGroupSplitIntervalListList,
@ -1063,7 +1063,7 @@ CreateSplitIntervalsForShardGroup(List *sourceColocatedShardIntervalList,
static void static void
CreateSplitIntervalsForShard(ShardInterval *sourceShard, CreateSplitIntervalsForShard(ShardInterval *sourceShard,
List *splitPointsForShard, List *splitPointsForShard,
List *needsIsolatedNodeForShardList, List *needsSeparateNodeForShardList,
List **shardSplitChildrenIntervalList) List **shardSplitChildrenIntervalList)
{ {
/* For 'N' split points, we will have N+1 shard intervals created. */ /* For 'N' split points, we will have N+1 shard intervals created. */
@ -1088,8 +1088,8 @@ CreateSplitIntervalsForShard(ShardInterval *sourceShard,
ShardInterval *splitChildShardInterval = CopyShardInterval(sourceShard); ShardInterval *splitChildShardInterval = CopyShardInterval(sourceShard);
splitChildShardInterval->shardIndex = -1; splitChildShardInterval->shardIndex = -1;
splitChildShardInterval->shardId = GetNextShardIdForSplitChild(); splitChildShardInterval->shardId = GetNextShardIdForSplitChild();
splitChildShardInterval->needsIsolatedNode = splitChildShardInterval->needsSeparateNode =
list_nth_int(needsIsolatedNodeForShardList, index); list_nth_int(needsSeparateNodeForShardList, index);
splitChildShardInterval->minValueExists = true; splitChildShardInterval->minValueExists = true;
splitChildShardInterval->minValue = currentSplitChildMinValue; splitChildShardInterval->minValue = currentSplitChildMinValue;
splitChildShardInterval->maxValueExists = true; splitChildShardInterval->maxValueExists = true;
@ -1192,7 +1192,7 @@ InsertSplitChildrenShardMetadata(List *shardGroupSplitIntervalListList,
shardInterval->storageType, shardInterval->storageType,
IntegerToText(DatumGetInt32(shardInterval->minValue)), IntegerToText(DatumGetInt32(shardInterval->minValue)),
IntegerToText(DatumGetInt32(shardInterval->maxValue)), IntegerToText(DatumGetInt32(shardInterval->maxValue)),
shardInterval->needsIsolatedNode); shardInterval->needsSeparateNode);
InsertShardPlacementRow( InsertShardPlacementRow(
shardInterval->shardId, shardInterval->shardId,
@ -1388,7 +1388,7 @@ AcquireNonblockingSplitLock(Oid relationId)
* sourceColocatedShardIntervalList : Source shard group to be split. * sourceColocatedShardIntervalList : Source shard group to be split.
* shardSplitPointsList : Split Points list for the source 'shardInterval'. * shardSplitPointsList : Split Points list for the source 'shardInterval'.
* workersForPlacementList : Placement list corresponding to split children. * workersForPlacementList : Placement list corresponding to split children.
* needsIsolatedNodeForShardList : Whether each split children needs an isolated node. * needsSeparateNodeForShardList : Whether each split children needs a separate node.
* distributionColumnList : Maps relation IDs to distribution columns. * distributionColumnList : Maps relation IDs to distribution columns.
* If not specified, the distribution column is read * If not specified, the distribution column is read
* from the metadata. * from the metadata.
@ -1401,7 +1401,7 @@ NonBlockingShardSplit(SplitOperation splitOperation,
List *sourceColocatedShardIntervalList, List *sourceColocatedShardIntervalList,
List *shardSplitPointsList, List *shardSplitPointsList,
List *workersForPlacementList, List *workersForPlacementList,
List *needsIsolatedNodeForShardList, List *needsSeparateNodeForShardList,
DistributionColumnMap *distributionColumnOverrides, DistributionColumnMap *distributionColumnOverrides,
uint32 targetColocationId) uint32 targetColocationId)
{ {
@ -1416,7 +1416,7 @@ NonBlockingShardSplit(SplitOperation splitOperation,
List *shardGroupSplitIntervalListList = CreateSplitIntervalsForShardGroup( List *shardGroupSplitIntervalListList = CreateSplitIntervalsForShardGroup(
sourceColocatedShardIntervalList, sourceColocatedShardIntervalList,
shardSplitPointsList, shardSplitPointsList,
needsIsolatedNodeForShardList); needsSeparateNodeForShardList);
ShardInterval *firstShard = linitial(sourceColocatedShardIntervalList); ShardInterval *firstShard = linitial(sourceColocatedShardIntervalList);

View File

@ -198,9 +198,9 @@ master_create_empty_shard(PG_FUNCTION_ARGS)
candidateNodeIndex++; candidateNodeIndex++;
} }
bool needsIsolatedNode = false; bool needsSeparateNode = false;
InsertShardRow(relationId, shardId, storageType, nullMinValue, nullMaxValue, InsertShardRow(relationId, shardId, storageType, nullMinValue, nullMaxValue,
needsIsolatedNode); needsSeparateNode);
CreateAppendDistributedShardPlacements(relationId, shardId, candidateNodeList, CreateAppendDistributedShardPlacements(relationId, shardId, candidateNodeList,
ShardReplicationFactor); ShardReplicationFactor);

View File

@ -285,7 +285,7 @@ NewDistributedTablePlacementNodeList(LOCKMODE lockMode)
/* /*
* NodeCanBeUsedForNonIsolatedPlacements returns true if given node can be * NodeCanBeUsedForNonIsolatedPlacements returns true if given node can be
* used to store shard placements that don't need isolation. * used to store shard placements that don't need separate nodes.
*/ */
bool bool
NodeCanBeUsedForNonIsolatedPlacements(WorkerNode *node) NodeCanBeUsedForNonIsolatedPlacements(WorkerNode *node)
@ -300,7 +300,7 @@ NodeCanBeUsedForNonIsolatedPlacements(WorkerNode *node)
return false; return false;
} }
return NodeGroupGetIsolatedShardPlacementGroup(node->groupId) == NULL; return NodeGroupGetSeparatedShardPlacementGroup(node->groupId) == NULL;
} }

View File

@ -4521,7 +4521,7 @@ GenerateSyntheticShardIntervalArray(int partitionCount)
shardInterval->shardId = INVALID_SHARD_ID; shardInterval->shardId = INVALID_SHARD_ID;
shardInterval->valueTypeId = INT4OID; shardInterval->valueTypeId = INT4OID;
shardInterval->needsIsolatedNode = false; shardInterval->needsSeparateNode = false;
shardIntervalArray[shardIndex] = shardInterval; shardIntervalArray[shardIndex] = shardInterval;
} }

View File

@ -4,10 +4,10 @@
#include "udfs/citus_add_rebalance_strategy/12.2-1.sql" #include "udfs/citus_add_rebalance_strategy/12.2-1.sql"
ALTER TABLE pg_dist_shard ADD COLUMN needsisolatednode boolean NOT NULL DEFAULT false; ALTER TABLE pg_dist_shard ADD COLUMN needsseparatenode boolean NOT NULL DEFAULT false;
#include "udfs/citus_internal_add_shard_metadata/12.2-1.sql" #include "udfs/citus_internal_add_shard_metadata/12.2-1.sql"
#include "udfs/citus_internal_shard_group_set_needsisolatednode/12.2-1.sql" #include "udfs/citus_internal_shard_group_set_needsseparatenode/12.2-1.sql"
#include "udfs/citus_shard_property_set/12.2-1.sql" #include "udfs/citus_shard_property_set/12.2-1.sql"
DROP VIEW citus_shards; DROP VIEW citus_shards;

View File

@ -10,8 +10,8 @@ DROP FUNCTION pg_catalog.citus_internal_add_shard_metadata(regclass, bigint, "ch
DROP FUNCTION pg_catalog.citus_shard_property_set(shard_id bigint, anti_affinity boolean); DROP FUNCTION pg_catalog.citus_shard_property_set(shard_id bigint, anti_affinity boolean);
DROP FUNCTION pg_catalog.citus_internal_shard_group_set_needsisolatednode( DROP FUNCTION pg_catalog.citus_internal_shard_group_set_needsseparatenode(
shard_id bigint, shard_id bigint,
enabled boolean); enabled boolean);
ALTER TABLE pg_dist_shard DROP COLUMN needsisolatednode; ALTER TABLE pg_dist_shard DROP COLUMN needsseparatenode;

View File

@ -1,8 +1,8 @@
-- create a new function, with needs_isolated_node -- create a new function, with needs_separate_node
CREATE OR REPLACE FUNCTION pg_catalog.citus_internal_add_shard_metadata( CREATE OR REPLACE FUNCTION pg_catalog.citus_internal_add_shard_metadata(
relation_id regclass, shard_id bigint, relation_id regclass, shard_id bigint,
storage_type "char", shard_min_value text, storage_type "char", shard_min_value text,
shard_max_value text, needs_isolated_node boolean shard_max_value text, needs_separate_node boolean
) )
RETURNS void RETURNS void
LANGUAGE C LANGUAGE C
@ -10,7 +10,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_internal_add_shard_metadata(
COMMENT ON FUNCTION pg_catalog.citus_internal_add_shard_metadata(regclass, bigint, "char", text, text, boolean) IS COMMENT ON FUNCTION pg_catalog.citus_internal_add_shard_metadata(regclass, bigint, "char", text, text, boolean) IS
'Inserts into pg_dist_shard with user checks'; 'Inserts into pg_dist_shard with user checks';
-- replace the old one so it would call the old C function without needs_isolated_node -- replace the old one so it would call the old C function without needs_separate_node
CREATE OR REPLACE FUNCTION pg_catalog.citus_internal_add_shard_metadata( CREATE OR REPLACE FUNCTION pg_catalog.citus_internal_add_shard_metadata(
relation_id regclass, shard_id bigint, relation_id regclass, shard_id bigint,
storage_type "char", shard_min_value text, storage_type "char", shard_min_value text,

View File

@ -1,8 +1,8 @@
-- create a new function, with needs_isolated_node -- create a new function, with needs_separate_node
CREATE OR REPLACE FUNCTION pg_catalog.citus_internal_add_shard_metadata( CREATE OR REPLACE FUNCTION pg_catalog.citus_internal_add_shard_metadata(
relation_id regclass, shard_id bigint, relation_id regclass, shard_id bigint,
storage_type "char", shard_min_value text, storage_type "char", shard_min_value text,
shard_max_value text, needs_isolated_node boolean shard_max_value text, needs_separate_node boolean
) )
RETURNS void RETURNS void
LANGUAGE C LANGUAGE C
@ -10,7 +10,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_internal_add_shard_metadata(
COMMENT ON FUNCTION pg_catalog.citus_internal_add_shard_metadata(regclass, bigint, "char", text, text, boolean) IS COMMENT ON FUNCTION pg_catalog.citus_internal_add_shard_metadata(regclass, bigint, "char", text, text, boolean) IS
'Inserts into pg_dist_shard with user checks'; 'Inserts into pg_dist_shard with user checks';
-- replace the old one so it would call the old C function without needs_isolated_node -- replace the old one so it would call the old C function without needs_separate_node
CREATE OR REPLACE FUNCTION pg_catalog.citus_internal_add_shard_metadata( CREATE OR REPLACE FUNCTION pg_catalog.citus_internal_add_shard_metadata(
relation_id regclass, shard_id bigint, relation_id regclass, shard_id bigint,
storage_type "char", shard_min_value text, storage_type "char", shard_min_value text,

View File

@ -1,6 +1,6 @@
CREATE OR REPLACE FUNCTION pg_catalog.citus_internal_shard_group_set_needsisolatednode( CREATE OR REPLACE FUNCTION pg_catalog.citus_internal_shard_group_set_needsseparatenode(
shard_id bigint, shard_id bigint,
enabled boolean) enabled boolean)
RETURNS void RETURNS void
LANGUAGE C VOLATILE LANGUAGE C VOLATILE
AS 'MODULE_PATHNAME', $$citus_internal_shard_group_set_needsisolatednode$$; AS 'MODULE_PATHNAME', $$citus_internal_shard_group_set_needsseparatenode$$;

View File

@ -1,6 +1,6 @@
CREATE OR REPLACE FUNCTION pg_catalog.citus_internal_shard_group_set_needsisolatednode( CREATE OR REPLACE FUNCTION pg_catalog.citus_internal_shard_group_set_needsseparatenode(
shard_id bigint, shard_id bigint,
enabled boolean) enabled boolean)
RETURNS void RETURNS void
LANGUAGE C VOLATILE LANGUAGE C VOLATILE
AS 'MODULE_PATHNAME', $$citus_internal_shard_group_set_needsisolatednode$$; AS 'MODULE_PATHNAME', $$citus_internal_shard_group_set_needsseparatenode$$;

View File

@ -13,7 +13,7 @@ SELECT
pg_dist_node.nodeport, pg_dist_node.nodeport,
size as shard_size, size as shard_size,
CASE CASE
WHEN NOT pg_dist_shard.needsisolatednode THEN false WHEN NOT pg_dist_shard.needsseparatenode THEN false
ELSE ELSE
-- has_separate_node = true if the node doesn't have any other shards except the ones that are colocated with this shard -- has_separate_node = true if the node doesn't have any other shards except the ones that are colocated with this shard
NOT EXISTS ( NOT EXISTS (

View File

@ -13,7 +13,7 @@ SELECT
pg_dist_node.nodeport, pg_dist_node.nodeport,
size as shard_size, size as shard_size,
CASE CASE
WHEN NOT pg_dist_shard.needsisolatednode THEN false WHEN NOT pg_dist_shard.needsseparatenode THEN false
ELSE ELSE
-- has_separate_node = true if the node doesn't have any other shards except the ones that are colocated with this shard -- has_separate_node = true if the node doesn't have any other shards except the ones that are colocated with this shard
NOT EXISTS ( NOT EXISTS (

View File

@ -228,9 +228,9 @@ create_monolithic_shard_row(PG_FUNCTION_ARGS)
text *minInfoText = cstring_to_text(minInfo->data); text *minInfoText = cstring_to_text(minInfo->data);
text *maxInfoText = cstring_to_text(maxInfo->data); text *maxInfoText = cstring_to_text(maxInfo->data);
bool needsIsolatedNode = false; bool needsSeparateNode = false;
InsertShardRow(distributedTableId, newShardId, SHARD_STORAGE_TABLE, minInfoText, InsertShardRow(distributedTableId, newShardId, SHARD_STORAGE_TABLE, minInfoText,
maxInfoText, needsIsolatedNode); maxInfoText, needsSeparateNode);
PG_RETURN_INT64(newShardId); PG_RETURN_INT64(newShardId);
} }

View File

@ -141,7 +141,7 @@ extern char * TenantSchemaInsertCommand(Oid schemaId, uint32 colocationId);
extern char * TenantSchemaDeleteCommand(char *schemaName); extern char * TenantSchemaDeleteCommand(char *schemaName);
extern char * UpdateNoneDistTableMetadataCommand(Oid relationId, char replicationModel, extern char * UpdateNoneDistTableMetadataCommand(Oid relationId, char replicationModel,
uint32 colocationId, bool autoConverted); uint32 colocationId, bool autoConverted);
extern char * ShardGroupSetNeedsIsolatedNodeCommand(uint64 shardId, bool enabled); extern char * ShardGroupSetNeedsSeparateNodeCommand(uint64 shardId, bool enabled);
extern char * AddPlacementMetadataCommand(uint64 shardId, uint64 placementId, extern char * AddPlacementMetadataCommand(uint64 shardId, uint64 placementId,
uint64 shardLength, int32 groupId); uint64 shardLength, int32 groupId);
extern char * DeletePlacementMetadataCommand(uint64 placementId); extern char * DeletePlacementMetadataCommand(uint64 placementId);

View File

@ -67,7 +67,7 @@ typedef struct ShardInterval
Datum maxValue; /* a shard's typed max value datum */ Datum maxValue; /* a shard's typed max value datum */
uint64 shardId; uint64 shardId;
int shardIndex; int shardIndex;
bool needsIsolatedNode; bool needsSeparateNode;
} ShardInterval; } ShardInterval;
@ -331,7 +331,7 @@ extern int ShardIntervalCount(Oid relationId);
extern List * LoadShardList(Oid relationId); extern List * LoadShardList(Oid relationId);
extern ShardInterval * CopyShardInterval(ShardInterval *srcInterval); extern ShardInterval * CopyShardInterval(ShardInterval *srcInterval);
extern uint64 ShardLength(uint64 shardId); extern uint64 ShardLength(uint64 shardId);
extern ShardPlacementGroup * NodeGroupGetIsolatedShardPlacementGroup(int32 groupId); extern ShardPlacementGroup * NodeGroupGetSeparatedShardPlacementGroup(int32 groupId);
extern bool ShardPlacementGroupsSame(const ShardPlacementGroup *leftGroup, extern bool ShardPlacementGroupsSame(const ShardPlacementGroup *leftGroup,
const ShardPlacementGroup *rightGroup); const ShardPlacementGroup *rightGroup);
extern bool NodeGroupHasShardPlacements(int32 groupId); extern bool NodeGroupHasShardPlacements(int32 groupId);
@ -363,7 +363,7 @@ extern List * RemoveCoordinatorPlacementIfNotSingleNode(List *placementList);
/* Function declarations to modify shard and shard placement data */ /* Function declarations to modify shard and shard placement data */
extern void InsertShardRow(Oid relationId, uint64 shardId, char storageType, extern void InsertShardRow(Oid relationId, uint64 shardId, char storageType,
text *shardMinValue, text *shardMaxValue, text *shardMinValue, text *shardMaxValue,
bool needsIsolatedNode); bool needsSeparateNode);
extern void DeleteShardRow(uint64 shardId); extern void DeleteShardRow(uint64 shardId);
extern ShardPlacement * InsertShardPlacementRowGlobally(uint64 shardId, extern ShardPlacement * InsertShardPlacementRowGlobally(uint64 shardId,
uint64 placementId, uint64 placementId,
@ -446,7 +446,7 @@ extern List * SendShardStatisticsQueriesInParallel(List *citusTableIds,
extern bool GetNodeDiskSpaceStatsForConnection(MultiConnection *connection, extern bool GetNodeDiskSpaceStatsForConnection(MultiConnection *connection,
uint64 *availableBytes, uint64 *availableBytes,
uint64 *totalBytes); uint64 *totalBytes);
extern void ShardGroupSetNeedsIsolatedNode(uint64 shardId, bool enabled); extern void ShardGroupSetNeedsSeparateNode(uint64 shardId, bool enabled);
extern void ExecuteQueryViaSPI(char *query, int SPIOK); extern void ExecuteQueryViaSPI(char *query, int SPIOK);
extern void ExecuteAndLogQueryViaSPI(char *query, int SPIOK, int logLevel); extern void ExecuteAndLogQueryViaSPI(char *query, int SPIOK, int logLevel);
extern void EnsureSequenceTypeSupported(Oid seqOid, Oid attributeTypeId, Oid extern void EnsureSequenceTypeSupported(Oid seqOid, Oid attributeTypeId, Oid

View File

@ -30,7 +30,10 @@ typedef struct FormData_pg_dist_shard
text shardminvalue; /* partition key's minimum value in shard */ text shardminvalue; /* partition key's minimum value in shard */
text shardmaxvalue; /* partition key's maximum value in shard */ text shardmaxvalue; /* partition key's maximum value in shard */
#endif #endif
bool needsIsolatedNode; /* whether the placements of this shard need to be isolated */ bool needsSeparateNode; /*
* Whether the placements of this shard need to be
* separated from others.
*/
} FormData_pg_dist_shard; } FormData_pg_dist_shard;
/* ---------------- /* ----------------
@ -51,7 +54,7 @@ typedef FormData_pg_dist_shard *Form_pg_dist_shard;
#define Anum_pg_dist_shard_shardalias_DROPPED 4 #define Anum_pg_dist_shard_shardalias_DROPPED 4
#define Anum_pg_dist_shard_shardminvalue 5 #define Anum_pg_dist_shard_shardminvalue 5
#define Anum_pg_dist_shard_shardmaxvalue 6 #define Anum_pg_dist_shard_shardmaxvalue 6
#define Anum_pg_dist_shard_needsisolatednode 7 #define Anum_pg_dist_shard_needsseparatenode 7
/* /*
* Valid values for shard storage types include foreign table, (standard) table * Valid values for shard storage types include foreign table, (standard) table

View File

@ -1,8 +1,8 @@
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* *
* rebalancer_placement_isolation.h * rebalancer_placement_isolation.h
* Routines to determine which worker node should be used to isolate * Routines to determine which worker node should be used to separate
* a colocated set of shard placements that need isolation. * a colocated set of shard placements that need separate nodes.
* *
* Copyright (c) Citus Data, Inc. * Copyright (c) Citus Data, Inc.
* *

View File

@ -43,7 +43,7 @@ extern void SplitShard(SplitMode splitMode,
uint64 shardIdToSplit, uint64 shardIdToSplit,
List *shardSplitPointsList, List *shardSplitPointsList,
List *nodeIdsForPlacementList, List *nodeIdsForPlacementList,
List *needsIsolatedNodeForPlacementList, List *needsSeparateNodeForPlacementList,
DistributionColumnMap *distributionColumnOverrides, DistributionColumnMap *distributionColumnOverrides,
List *colocatedShardIntervalList, List *colocatedShardIntervalList,
uint32 targetColocationId); uint32 targetColocationId);

View File

@ -189,7 +189,7 @@ SELECT create_distributed_table_concurrently('table_1', 'id');
(1 row) (1 row)
SELECT * FROM pg_dist_shard WHERE logicalrelid = 'table_1'::regclass; SELECT * FROM pg_dist_shard WHERE logicalrelid = 'table_1'::regclass;
logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsisolatednode logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsseparatenode
--------------------------------------------------------------------- ---------------------------------------------------------------------
table_1 | 222247 | t | -2147483648 | -1 | f table_1 | 222247 | t | -2147483648 | -1 | f
table_1 | 222248 | t | 0 | 2147483647 | f table_1 | 222248 | t | 0 | 2147483647 | f

View File

@ -30,9 +30,9 @@ $func$ LANGUAGE plpgsql;
CREATE SCHEMA isolate_placement; CREATE SCHEMA isolate_placement;
SET search_path TO isolate_placement; SET search_path TO isolate_placement;
-- test null input -- test null input
SELECT citus_internal_shard_group_set_needsisolatednode(0, NULL); SELECT citus_internal_shard_group_set_needsseparatenode(0, NULL);
ERROR: enabled cannot be NULL ERROR: enabled cannot be NULL
SELECT citus_internal_shard_group_set_needsisolatednode(NULL, false); SELECT citus_internal_shard_group_set_needsseparatenode(NULL, false);
ERROR: shard_id cannot be NULL ERROR: shard_id cannot be NULL
SET citus.shard_replication_factor TO 1; SET citus.shard_replication_factor TO 1;
SET citus.next_shard_id TO 2000000; SET citus.next_shard_id TO 2000000;
@ -44,7 +44,7 @@ SELECT create_distributed_table('single_shard_1', null, colocate_with=>'none');
(1 row) (1 row)
-- test with user that doesn't have permission to execute the function -- test with user that doesn't have permission to execute the function
SELECT citus_internal_shard_group_set_needsisolatednode(shardid, true) FROM pg_dist_shard WHERE logicalrelid = 'isolate_placement.single_shard_1'::regclass; SELECT citus_internal_shard_group_set_needsseparatenode(shardid, true) FROM pg_dist_shard WHERE logicalrelid = 'isolate_placement.single_shard_1'::regclass;
ERROR: This is an internal Citus function can only be used in a distributed transaction ERROR: This is an internal Citus function can only be used in a distributed transaction
DROP TABLE single_shard_1; DROP TABLE single_shard_1;
CREATE ROLE test_user_isolate_placement WITH LOGIN; CREATE ROLE test_user_isolate_placement WITH LOGIN;
@ -64,17 +64,17 @@ SELECT pg_sleep(0.1);
SET ROLE test_user_isolate_placement; SET ROLE test_user_isolate_placement;
-- test invalid shard id -- test invalid shard id
SELECT citus_internal_shard_group_set_needsisolatednode(0, true); SELECT citus_internal_shard_group_set_needsseparatenode(0, true);
ERROR: could not find valid entry for shard xxxxx ERROR: could not find valid entry for shard xxxxx
-- test null needs_isolated_node -- test null needs_separate_node
SELECT citus_internal_add_shard_metadata( SELECT citus_internal_add_shard_metadata(
relation_id=>0, relation_id=>0,
shard_id=>0, shard_id=>0,
storage_type=>'0', storage_type=>'0',
shard_min_value=>'0', shard_min_value=>'0',
shard_max_value=>'0', shard_max_value=>'0',
needs_isolated_node=>null); needs_separate_node=>null);
ERROR: needs isolated node cannot be NULL ERROR: needs separate node cannot be NULL
RESET ROLE; RESET ROLE;
REVOKE ALL ON SCHEMA isolate_placement FROM test_user_isolate_placement; REVOKE ALL ON SCHEMA isolate_placement FROM test_user_isolate_placement;
DROP USER test_user_isolate_placement; DROP USER test_user_isolate_placement;
@ -124,7 +124,7 @@ SELECT citus_shard_property_set(shardid) FROM pg_dist_shard WHERE logicalrelid =
ERROR: must be owner of table single_shard_1 ERROR: must be owner of table single_shard_1
SELECT citus_shard_property_set(shardid, anti_affinity=>true) FROM pg_dist_shard WHERE logicalrelid = 'isolate_placement.single_shard_1'::regclass; SELECT citus_shard_property_set(shardid, anti_affinity=>true) FROM pg_dist_shard WHERE logicalrelid = 'isolate_placement.single_shard_1'::regclass;
ERROR: must be owner of table single_shard_1 ERROR: must be owner of table single_shard_1
SELECT citus_internal_shard_group_set_needsisolatednode(shardid, true) FROM pg_dist_shard WHERE logicalrelid = 'isolate_placement.single_shard_1'::regclass; SELECT citus_internal_shard_group_set_needsseparatenode(shardid, true) FROM pg_dist_shard WHERE logicalrelid = 'isolate_placement.single_shard_1'::regclass;
ERROR: must be owner of table single_shard_1 ERROR: must be owner of table single_shard_1
-- assign all tables to regularuser -- assign all tables to regularuser
RESET ROLE; RESET ROLE;
@ -154,8 +154,8 @@ ORDER BY result;
[{"1": [{"isolate_placement.single_shard_1": true}]}] [{"1": [{"isolate_placement.single_shard_1": true}]}]
(3 rows) (3 rows)
SELECT citus_internal_shard_group_set_needsisolatednode(shardid, false) FROM pg_dist_shard WHERE logicalrelid = 'isolate_placement.single_shard_1'::regclass; SELECT citus_internal_shard_group_set_needsseparatenode(shardid, false) FROM pg_dist_shard WHERE logicalrelid = 'isolate_placement.single_shard_1'::regclass;
citus_internal_shard_group_set_needsisolatednode citus_internal_shard_group_set_needsseparatenode
--------------------------------------------------------------------- ---------------------------------------------------------------------
(1 row) (1 row)
@ -171,8 +171,8 @@ ORDER BY result;
{} {}
(3 rows) (3 rows)
SELECT citus_internal_shard_group_set_needsisolatednode(shardid, true) FROM pg_dist_shard WHERE logicalrelid = 'isolate_placement.single_shard_1'::regclass; SELECT citus_internal_shard_group_set_needsseparatenode(shardid, true) FROM pg_dist_shard WHERE logicalrelid = 'isolate_placement.single_shard_1'::regclass;
citus_internal_shard_group_set_needsisolatednode citus_internal_shard_group_set_needsseparatenode
--------------------------------------------------------------------- ---------------------------------------------------------------------
(1 row) (1 row)
@ -229,7 +229,7 @@ SELECT create_distributed_table('dist_3', 'a', colocate_with=>'dist_1');
(1 row) (1 row)
SET citus.shard_replication_factor TO 1; SET citus.shard_replication_factor TO 1;
-- none of the placements have been marked as needsisolatednode yet -- none of the placements have been marked as needsseparatenode yet
SELECT result FROM run_command_on_all_nodes($$ SELECT result FROM run_command_on_all_nodes($$
SELECT * FROM public.get_colocated_shards_needisolatednode('isolate_placement.dist_1') SELECT * FROM public.get_colocated_shards_needisolatednode('isolate_placement.dist_1')
$$) $$)
@ -403,7 +403,7 @@ DETAIL: UPDATE and DELETE commands on the relation will error out during create
(1 row) (1 row)
-- Placements of a new distributed table created within the same colocated -- Placements of a new distributed table created within the same colocated
-- group inherit needsisolatednode from the colocated placements too. -- group inherit needsseparatenode from the colocated placements too.
SELECT result FROM run_command_on_all_nodes($$ SELECT result FROM run_command_on_all_nodes($$
SELECT * FROM public.get_colocated_shards_needisolatednode('isolate_placement.dist_1') SELECT * FROM public.get_colocated_shards_needisolatednode('isolate_placement.dist_1')
$$) $$)
@ -602,7 +602,7 @@ WHERE shardid = :shardgroup_9_shardid;
(1 row) (1 row)
-- We shouldn't see shard group 9 because shard-split operation doesn't -- We shouldn't see shard group 9 because shard-split operation doesn't
-- preserve needsisolatednode flag when splitting the shard. -- preserve needsseparatenode flag when splitting the shard.
SELECT result FROM run_command_on_all_nodes($$ SELECT result FROM run_command_on_all_nodes($$
SELECT * FROM public.get_colocated_shards_needisolatednode('isolate_placement.dist_1') SELECT * FROM public.get_colocated_shards_needisolatednode('isolate_placement.dist_1')
$$) $$)
@ -703,7 +703,7 @@ SELECT 1 FROM isolate_tenant_to_new_shard('dist_3', 100, shard_transfer_mode =>
(1 row) (1 row)
-- We shouldn't see shard group 17 because isolate_tenant_to_new_shard doesn't -- We shouldn't see shard group 17 because isolate_tenant_to_new_shard doesn't
-- preserve needsisolatednode flag when splitting the shard. -- preserve needsseparatenode flag when splitting the shard.
SELECT result FROM run_command_on_all_nodes($$ SELECT result FROM run_command_on_all_nodes($$
SELECT * FROM public.get_colocated_shards_needisolatednode('isolate_placement.dist_3') SELECT * FROM public.get_colocated_shards_needisolatednode('isolate_placement.dist_3')
$$) $$)

View File

@ -57,7 +57,7 @@ step s2-print-status:
-- sanity check on total elements in the table -- sanity check on total elements in the table
SELECT COUNT(*) FROM table_1; SELECT COUNT(*) FROM table_1;
logicalrelid|shardid|shardstorage|shardminvalue|shardmaxvalue|needsisolatednode logicalrelid|shardid|shardstorage|shardminvalue|shardmaxvalue|needsseparatenode
--------------------------------------------------------------------- ---------------------------------------------------------------------
table_1 |1400306|t | -2147483648| -1073741825|f table_1 |1400306|t | -2147483648| -1073741825|f
table_1 |1400307|t | -1073741824| -1|f table_1 |1400307|t | -1073741824| -1|f
@ -125,7 +125,7 @@ step s2-print-status:
-- sanity check on total elements in the table -- sanity check on total elements in the table
SELECT COUNT(*) FROM table_1; SELECT COUNT(*) FROM table_1;
logicalrelid|shardid|shardstorage|shardminvalue|shardmaxvalue|needsisolatednode logicalrelid|shardid|shardstorage|shardminvalue|shardmaxvalue|needsseparatenode
--------------------------------------------------------------------- ---------------------------------------------------------------------
table_1 |1400311|t | -2147483648| -1073741825|f table_1 |1400311|t | -2147483648| -1073741825|f
table_1 |1400312|t | -1073741824| -1|f table_1 |1400312|t | -1073741824| -1|f
@ -193,7 +193,7 @@ step s2-print-status:
-- sanity check on total elements in the table -- sanity check on total elements in the table
SELECT COUNT(*) FROM table_1; SELECT COUNT(*) FROM table_1;
logicalrelid|shardid|shardstorage|shardminvalue|shardmaxvalue|needsisolatednode logicalrelid|shardid|shardstorage|shardminvalue|shardmaxvalue|needsseparatenode
--------------------------------------------------------------------- ---------------------------------------------------------------------
table_1 |1400316|t | -2147483648| -1073741825|f table_1 |1400316|t | -2147483648| -1073741825|f
table_1 |1400317|t | -1073741824| -1|f table_1 |1400317|t | -1073741824| -1|f
@ -261,7 +261,7 @@ step s2-print-status:
-- sanity check on total elements in the table -- sanity check on total elements in the table
SELECT COUNT(*) FROM table_1; SELECT COUNT(*) FROM table_1;
logicalrelid|shardid|shardstorage|shardminvalue|shardmaxvalue|needsisolatednode logicalrelid|shardid|shardstorage|shardminvalue|shardmaxvalue|needsseparatenode
--------------------------------------------------------------------- ---------------------------------------------------------------------
table_1 |1400321|t | -2147483648| -1073741825|f table_1 |1400321|t | -2147483648| -1073741825|f
table_1 |1400322|t | -1073741824| -1|f table_1 |1400322|t | -1073741824| -1|f

View File

@ -1423,7 +1423,7 @@ SELECT * FROM multi_extension.print_extension_changes();
previous_object | current_object previous_object | current_object
--------------------------------------------------------------------- ---------------------------------------------------------------------
| function citus_internal_add_shard_metadata(regclass,bigint,"char",text,text,boolean) void | function citus_internal_add_shard_metadata(regclass,bigint,"char",text,text,boolean) void
| function citus_internal_shard_group_set_needsisolatednode(bigint,boolean) void | function citus_internal_shard_group_set_needsseparatenode(bigint,boolean) void
| function citus_shard_property_set(bigint,boolean) void | function citus_shard_property_set(bigint,boolean) void
(3 rows) (3 rows)

View File

@ -696,9 +696,9 @@ NOTICE: issuing SELECT citus_internal_add_partition_metadata ('fix_idx_names.p2
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
NOTICE: issuing SELECT citus_internal_add_partition_metadata ('fix_idx_names.p2'::regclass, 'h', 'dist_col', 1370001, 's') NOTICE: issuing SELECT citus_internal_add_partition_metadata ('fix_idx_names.p2'::regclass, 'h', 'dist_col', 1370001, 's')
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
NOTICE: issuing WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) AS (VALUES ('fix_idx_names.p2'::regclass, 915002, 't'::"char", '-2147483648', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) FROM shard_data; NOTICE: issuing WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) AS (VALUES ('fix_idx_names.p2'::regclass, 915002, 't'::"char", '-2147483648', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) FROM shard_data;
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
NOTICE: issuing WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) AS (VALUES ('fix_idx_names.p2'::regclass, 915002, 't'::"char", '-2147483648', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) FROM shard_data; NOTICE: issuing WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) AS (VALUES ('fix_idx_names.p2'::regclass, 915002, 't'::"char", '-2147483648', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) FROM shard_data;
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
NOTICE: issuing WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (xxxxxx, xxxxxx, xxxxxx, xxxxxx)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data; NOTICE: issuing WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (xxxxxx, xxxxxx, xxxxxx, xxxxxx)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data;
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx

View File

@ -45,7 +45,7 @@ select * from pg_dist_shard
where logicalrelid='lineitem'::regclass or where logicalrelid='lineitem'::regclass or
logicalrelid='orders'::regclass logicalrelid='orders'::regclass
order by shardid; order by shardid;
logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsisolatednode logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsseparatenode
--------------------------------------------------------------------- ---------------------------------------------------------------------
lineitem | 360000 | t | -2147483648 | -1 | f lineitem | 360000 | t | -2147483648 | -1 | f
lineitem | 360001 | t | 0 | 2147483647 | f lineitem | 360001 | t | 0 | 2147483647 | f

View File

@ -194,8 +194,8 @@ SELECT unnest(activate_node_snapshot()) order by 1;
WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('table', ARRAY['public', 'single_shard_tbl']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data; WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('table', ARRAY['public', 'single_shard_tbl']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data;
WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310000, 0, 1, 100000), (1310001, 0, 2, 100001), (1310002, 0, 1, 100002), (1310003, 0, 2, 100003), (1310004, 0, 1, 100004), (1310005, 0, 2, 100005), (1310006, 0, 1, 100006), (1310007, 0, 2, 100007)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data; WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310000, 0, 1, 100000), (1310001, 0, 2, 100001), (1310002, 0, 1, 100002), (1310003, 0, 2, 100003), (1310004, 0, 1, 100004), (1310005, 0, 2, 100005), (1310006, 0, 1, 100006), (1310007, 0, 2, 100007)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data;
WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310008, 0, 2, 100008)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data; WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310008, 0, 2, 100008)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data;
WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) AS (VALUES ('public.mx_test_table'::regclass, 1310000, 't'::"char", '-2147483648', '-1610612737', false), ('public.mx_test_table'::regclass, 1310001, 't'::"char", '-1610612736', '-1073741825', false), ('public.mx_test_table'::regclass, 1310002, 't'::"char", '-1073741824', '-536870913', false), ('public.mx_test_table'::regclass, 1310003, 't'::"char", '-536870912', '-1', false), ('public.mx_test_table'::regclass, 1310004, 't'::"char", '0', '536870911', false), ('public.mx_test_table'::regclass, 1310005, 't'::"char", '536870912', '1073741823', false), ('public.mx_test_table'::regclass, 1310006, 't'::"char", '1073741824', '1610612735', false), ('public.mx_test_table'::regclass, 1310007, 't'::"char", '1610612736', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) FROM shard_data; WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) AS (VALUES ('public.mx_test_table'::regclass, 1310000, 't'::"char", '-2147483648', '-1610612737', false), ('public.mx_test_table'::regclass, 1310001, 't'::"char", '-1610612736', '-1073741825', false), ('public.mx_test_table'::regclass, 1310002, 't'::"char", '-1073741824', '-536870913', false), ('public.mx_test_table'::regclass, 1310003, 't'::"char", '-536870912', '-1', false), ('public.mx_test_table'::regclass, 1310004, 't'::"char", '0', '536870911', false), ('public.mx_test_table'::regclass, 1310005, 't'::"char", '536870912', '1073741823', false), ('public.mx_test_table'::regclass, 1310006, 't'::"char", '1073741824', '1610612735', false), ('public.mx_test_table'::regclass, 1310007, 't'::"char", '1610612736', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) FROM shard_data;
WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) AS (VALUES ('public.single_shard_tbl'::regclass, 1310008, 't'::"char", NULL, NULL, false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) FROM shard_data; WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) AS (VALUES ('public.single_shard_tbl'::regclass, 1310008, 't'::"char", NULL, NULL, false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) FROM shard_data;
(61 rows) (61 rows)
-- Drop single shard table -- Drop single shard table
@ -256,7 +256,7 @@ SELECT unnest(activate_node_snapshot()) order by 1;
WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('sequence', ARRAY['public', 'user_defined_seq']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data; WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('sequence', ARRAY['public', 'user_defined_seq']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data;
WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('table', ARRAY['public', 'mx_test_table']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data; WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('table', ARRAY['public', 'mx_test_table']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data;
WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310000, 0, 1, 100000), (1310001, 0, 2, 100001), (1310002, 0, 1, 100002), (1310003, 0, 2, 100003), (1310004, 0, 1, 100004), (1310005, 0, 2, 100005), (1310006, 0, 1, 100006), (1310007, 0, 2, 100007)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data; WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310000, 0, 1, 100000), (1310001, 0, 2, 100001), (1310002, 0, 1, 100002), (1310003, 0, 2, 100003), (1310004, 0, 1, 100004), (1310005, 0, 2, 100005), (1310006, 0, 1, 100006), (1310007, 0, 2, 100007)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data;
WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) AS (VALUES ('public.mx_test_table'::regclass, 1310000, 't'::"char", '-2147483648', '-1610612737', false), ('public.mx_test_table'::regclass, 1310001, 't'::"char", '-1610612736', '-1073741825', false), ('public.mx_test_table'::regclass, 1310002, 't'::"char", '-1073741824', '-536870913', false), ('public.mx_test_table'::regclass, 1310003, 't'::"char", '-536870912', '-1', false), ('public.mx_test_table'::regclass, 1310004, 't'::"char", '0', '536870911', false), ('public.mx_test_table'::regclass, 1310005, 't'::"char", '536870912', '1073741823', false), ('public.mx_test_table'::regclass, 1310006, 't'::"char", '1073741824', '1610612735', false), ('public.mx_test_table'::regclass, 1310007, 't'::"char", '1610612736', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) FROM shard_data; WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) AS (VALUES ('public.mx_test_table'::regclass, 1310000, 't'::"char", '-2147483648', '-1610612737', false), ('public.mx_test_table'::regclass, 1310001, 't'::"char", '-1610612736', '-1073741825', false), ('public.mx_test_table'::regclass, 1310002, 't'::"char", '-1073741824', '-536870913', false), ('public.mx_test_table'::regclass, 1310003, 't'::"char", '-536870912', '-1', false), ('public.mx_test_table'::regclass, 1310004, 't'::"char", '0', '536870911', false), ('public.mx_test_table'::regclass, 1310005, 't'::"char", '536870912', '1073741823', false), ('public.mx_test_table'::regclass, 1310006, 't'::"char", '1073741824', '1610612735', false), ('public.mx_test_table'::regclass, 1310007, 't'::"char", '1610612736', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) FROM shard_data;
(52 rows) (52 rows)
-- Show that schema changes are included in the activate node snapshot -- Show that schema changes are included in the activate node snapshot
@ -318,7 +318,7 @@ SELECT unnest(activate_node_snapshot()) order by 1;
WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('sequence', ARRAY['public', 'user_defined_seq']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data; WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('sequence', ARRAY['public', 'user_defined_seq']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data;
WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('table', ARRAY['mx_testing_schema', 'mx_test_table']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data; WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('table', ARRAY['mx_testing_schema', 'mx_test_table']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data;
WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310000, 0, 1, 100000), (1310001, 0, 2, 100001), (1310002, 0, 1, 100002), (1310003, 0, 2, 100003), (1310004, 0, 1, 100004), (1310005, 0, 2, 100005), (1310006, 0, 1, 100006), (1310007, 0, 2, 100007)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data; WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310000, 0, 1, 100000), (1310001, 0, 2, 100001), (1310002, 0, 1, 100002), (1310003, 0, 2, 100003), (1310004, 0, 1, 100004), (1310005, 0, 2, 100005), (1310006, 0, 1, 100006), (1310007, 0, 2, 100007)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data;
WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) AS (VALUES ('mx_testing_schema.mx_test_table'::regclass, 1310000, 't'::"char", '-2147483648', '-1610612737', false), ('mx_testing_schema.mx_test_table'::regclass, 1310001, 't'::"char", '-1610612736', '-1073741825', false), ('mx_testing_schema.mx_test_table'::regclass, 1310002, 't'::"char", '-1073741824', '-536870913', false), ('mx_testing_schema.mx_test_table'::regclass, 1310003, 't'::"char", '-536870912', '-1', false), ('mx_testing_schema.mx_test_table'::regclass, 1310004, 't'::"char", '0', '536870911', false), ('mx_testing_schema.mx_test_table'::regclass, 1310005, 't'::"char", '536870912', '1073741823', false), ('mx_testing_schema.mx_test_table'::regclass, 1310006, 't'::"char", '1073741824', '1610612735', false), ('mx_testing_schema.mx_test_table'::regclass, 1310007, 't'::"char", '1610612736', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) FROM shard_data; WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) AS (VALUES ('mx_testing_schema.mx_test_table'::regclass, 1310000, 't'::"char", '-2147483648', '-1610612737', false), ('mx_testing_schema.mx_test_table'::regclass, 1310001, 't'::"char", '-1610612736', '-1073741825', false), ('mx_testing_schema.mx_test_table'::regclass, 1310002, 't'::"char", '-1073741824', '-536870913', false), ('mx_testing_schema.mx_test_table'::regclass, 1310003, 't'::"char", '-536870912', '-1', false), ('mx_testing_schema.mx_test_table'::regclass, 1310004, 't'::"char", '0', '536870911', false), ('mx_testing_schema.mx_test_table'::regclass, 1310005, 't'::"char", '536870912', '1073741823', false), ('mx_testing_schema.mx_test_table'::regclass, 1310006, 't'::"char", '1073741824', '1610612735', false), ('mx_testing_schema.mx_test_table'::regclass, 1310007, 't'::"char", '1610612736', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) FROM shard_data;
(54 rows) (54 rows)
-- Show that append distributed tables are not included in the activate node snapshot -- Show that append distributed tables are not included in the activate node snapshot
@ -386,7 +386,7 @@ SELECT unnest(activate_node_snapshot()) order by 1;
WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('sequence', ARRAY['public', 'user_defined_seq']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data; WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('sequence', ARRAY['public', 'user_defined_seq']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data;
WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('table', ARRAY['mx_testing_schema', 'mx_test_table']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data; WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('table', ARRAY['mx_testing_schema', 'mx_test_table']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data;
WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310000, 0, 1, 100000), (1310001, 0, 2, 100001), (1310002, 0, 1, 100002), (1310003, 0, 2, 100003), (1310004, 0, 1, 100004), (1310005, 0, 2, 100005), (1310006, 0, 1, 100006), (1310007, 0, 2, 100007)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data; WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310000, 0, 1, 100000), (1310001, 0, 2, 100001), (1310002, 0, 1, 100002), (1310003, 0, 2, 100003), (1310004, 0, 1, 100004), (1310005, 0, 2, 100005), (1310006, 0, 1, 100006), (1310007, 0, 2, 100007)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data;
WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) AS (VALUES ('mx_testing_schema.mx_test_table'::regclass, 1310000, 't'::"char", '-2147483648', '-1610612737', false), ('mx_testing_schema.mx_test_table'::regclass, 1310001, 't'::"char", '-1610612736', '-1073741825', false), ('mx_testing_schema.mx_test_table'::regclass, 1310002, 't'::"char", '-1073741824', '-536870913', false), ('mx_testing_schema.mx_test_table'::regclass, 1310003, 't'::"char", '-536870912', '-1', false), ('mx_testing_schema.mx_test_table'::regclass, 1310004, 't'::"char", '0', '536870911', false), ('mx_testing_schema.mx_test_table'::regclass, 1310005, 't'::"char", '536870912', '1073741823', false), ('mx_testing_schema.mx_test_table'::regclass, 1310006, 't'::"char", '1073741824', '1610612735', false), ('mx_testing_schema.mx_test_table'::regclass, 1310007, 't'::"char", '1610612736', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) FROM shard_data; WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) AS (VALUES ('mx_testing_schema.mx_test_table'::regclass, 1310000, 't'::"char", '-2147483648', '-1610612737', false), ('mx_testing_schema.mx_test_table'::regclass, 1310001, 't'::"char", '-1610612736', '-1073741825', false), ('mx_testing_schema.mx_test_table'::regclass, 1310002, 't'::"char", '-1073741824', '-536870913', false), ('mx_testing_schema.mx_test_table'::regclass, 1310003, 't'::"char", '-536870912', '-1', false), ('mx_testing_schema.mx_test_table'::regclass, 1310004, 't'::"char", '0', '536870911', false), ('mx_testing_schema.mx_test_table'::regclass, 1310005, 't'::"char", '536870912', '1073741823', false), ('mx_testing_schema.mx_test_table'::regclass, 1310006, 't'::"char", '1073741824', '1610612735', false), ('mx_testing_schema.mx_test_table'::regclass, 1310007, 't'::"char", '1610612736', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) FROM shard_data;
(54 rows) (54 rows)
-- Show that range distributed tables are not included in the activate node snapshot -- Show that range distributed tables are not included in the activate node snapshot
@ -447,7 +447,7 @@ SELECT unnest(activate_node_snapshot()) order by 1;
WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('sequence', ARRAY['public', 'user_defined_seq']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data; WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('sequence', ARRAY['public', 'user_defined_seq']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data;
WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('table', ARRAY['mx_testing_schema', 'mx_test_table']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data; WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('table', ARRAY['mx_testing_schema', 'mx_test_table']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data;
WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310000, 0, 1, 100000), (1310001, 0, 2, 100001), (1310002, 0, 1, 100002), (1310003, 0, 2, 100003), (1310004, 0, 1, 100004), (1310005, 0, 2, 100005), (1310006, 0, 1, 100006), (1310007, 0, 2, 100007)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data; WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310000, 0, 1, 100000), (1310001, 0, 2, 100001), (1310002, 0, 1, 100002), (1310003, 0, 2, 100003), (1310004, 0, 1, 100004), (1310005, 0, 2, 100005), (1310006, 0, 1, 100006), (1310007, 0, 2, 100007)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data;
WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) AS (VALUES ('mx_testing_schema.mx_test_table'::regclass, 1310000, 't'::"char", '-2147483648', '-1610612737', false), ('mx_testing_schema.mx_test_table'::regclass, 1310001, 't'::"char", '-1610612736', '-1073741825', false), ('mx_testing_schema.mx_test_table'::regclass, 1310002, 't'::"char", '-1073741824', '-536870913', false), ('mx_testing_schema.mx_test_table'::regclass, 1310003, 't'::"char", '-536870912', '-1', false), ('mx_testing_schema.mx_test_table'::regclass, 1310004, 't'::"char", '0', '536870911', false), ('mx_testing_schema.mx_test_table'::regclass, 1310005, 't'::"char", '536870912', '1073741823', false), ('mx_testing_schema.mx_test_table'::regclass, 1310006, 't'::"char", '1073741824', '1610612735', false), ('mx_testing_schema.mx_test_table'::regclass, 1310007, 't'::"char", '1610612736', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) FROM shard_data; WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) AS (VALUES ('mx_testing_schema.mx_test_table'::regclass, 1310000, 't'::"char", '-2147483648', '-1610612737', false), ('mx_testing_schema.mx_test_table'::regclass, 1310001, 't'::"char", '-1610612736', '-1073741825', false), ('mx_testing_schema.mx_test_table'::regclass, 1310002, 't'::"char", '-1073741824', '-536870913', false), ('mx_testing_schema.mx_test_table'::regclass, 1310003, 't'::"char", '-536870912', '-1', false), ('mx_testing_schema.mx_test_table'::regclass, 1310004, 't'::"char", '0', '536870911', false), ('mx_testing_schema.mx_test_table'::regclass, 1310005, 't'::"char", '536870912', '1073741823', false), ('mx_testing_schema.mx_test_table'::regclass, 1310006, 't'::"char", '1073741824', '1610612735', false), ('mx_testing_schema.mx_test_table'::regclass, 1310007, 't'::"char", '1610612736', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) FROM shard_data;
(54 rows) (54 rows)
-- Test start_metadata_sync_to_node and citus_activate_node UDFs -- Test start_metadata_sync_to_node and citus_activate_node UDFs
@ -537,7 +537,7 @@ SELECT * FROM pg_dist_partition WHERE logicalrelid::text LIKE 'mx_testing_schema
(1 row) (1 row)
SELECT * FROM pg_dist_shard WHERE logicalrelid::text LIKE 'mx_testing_schema%' ORDER BY shardid; SELECT * FROM pg_dist_shard WHERE logicalrelid::text LIKE 'mx_testing_schema%' ORDER BY shardid;
logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsisolatednode logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsseparatenode
--------------------------------------------------------------------- ---------------------------------------------------------------------
mx_testing_schema.mx_test_table | 1310000 | t | -2147483648 | -1610612737 | f mx_testing_schema.mx_test_table | 1310000 | t | -2147483648 | -1610612737 | f
mx_testing_schema.mx_test_table | 1310001 | t | -1610612736 | -1073741825 | f mx_testing_schema.mx_test_table | 1310001 | t | -1610612736 | -1073741825 | f
@ -676,7 +676,7 @@ SELECT * FROM pg_dist_partition WHERE logicalrelid::text LIKE 'mx_testing_schema
(1 row) (1 row)
SELECT * FROM pg_dist_shard WHERE logicalrelid::text LIKE 'mx_testing_schema%' ORDER BY shardid; SELECT * FROM pg_dist_shard WHERE logicalrelid::text LIKE 'mx_testing_schema%' ORDER BY shardid;
logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsisolatednode logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsseparatenode
--------------------------------------------------------------------- ---------------------------------------------------------------------
mx_testing_schema.mx_test_table | 1310000 | t | -2147483648 | -1610612737 | f mx_testing_schema.mx_test_table | 1310000 | t | -2147483648 | -1610612737 | f
mx_testing_schema.mx_test_table | 1310001 | t | -1610612736 | -1073741825 | f mx_testing_schema.mx_test_table | 1310001 | t | -1610612736 | -1073741825 | f
@ -1021,7 +1021,7 @@ SELECT * FROM pg_dist_partition WHERE logicalrelid::text LIKE 'mx_test_schema%';
(0 rows) (0 rows)
SELECT * FROM pg_dist_shard WHERE logicalrelid::text LIKE 'mx_test_schema%'; SELECT * FROM pg_dist_shard WHERE logicalrelid::text LIKE 'mx_test_schema%';
logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsisolatednode logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsseparatenode
--------------------------------------------------------------------- ---------------------------------------------------------------------
(0 rows) (0 rows)
@ -1681,7 +1681,7 @@ SELECT "Column", "Type", "Definition" FROM index_attrs WHERE
relid = 'mx_ref_index'::regclass; relid = 'mx_ref_index'::regclass;
ERROR: relation "mx_ref_index" does not exist ERROR: relation "mx_ref_index" does not exist
SELECT * FROM pg_dist_shard WHERE shardid=:ref_table_shardid; SELECT * FROM pg_dist_shard WHERE shardid=:ref_table_shardid;
logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsisolatednode logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsseparatenode
--------------------------------------------------------------------- ---------------------------------------------------------------------
(0 rows) (0 rows)
@ -2056,12 +2056,12 @@ SELECT unnest(activate_node_snapshot()) order by 1;
WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310075, 0, 0, 100077), (1310075, 0, 1, 100078), (1310075, 0, 5, 100079)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data; WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310075, 0, 0, 100077), (1310075, 0, 1, 100078), (1310075, 0, 5, 100079)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data;
WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310076, 0, 1, 100080), (1310077, 0, 5, 100081), (1310078, 0, 1, 100082), (1310079, 0, 5, 100083)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data; WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310076, 0, 1, 100080), (1310077, 0, 5, 100081), (1310078, 0, 1, 100082), (1310079, 0, 5, 100083)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data;
WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310085, 0, 1, 100091), (1310086, 0, 5, 100092), (1310087, 0, 1, 100093), (1310088, 0, 5, 100094)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data; WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310085, 0, 1, 100091), (1310086, 0, 5, 100092), (1310087, 0, 1, 100093), (1310088, 0, 5, 100094)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data;
WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) AS (VALUES ('mx_test_schema_1.mx_table_1'::regclass, 1310022, 't'::"char", '-2147483648', '-1288490190', false), ('mx_test_schema_1.mx_table_1'::regclass, 1310023, 't'::"char", '-1288490189', '-429496731', false), ('mx_test_schema_1.mx_table_1'::regclass, 1310024, 't'::"char", '-429496730', '429496728', false), ('mx_test_schema_1.mx_table_1'::regclass, 1310025, 't'::"char", '429496729', '1288490187', false), ('mx_test_schema_1.mx_table_1'::regclass, 1310026, 't'::"char", '1288490188', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) FROM shard_data; WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) AS (VALUES ('mx_test_schema_1.mx_table_1'::regclass, 1310022, 't'::"char", '-2147483648', '-1288490190', false), ('mx_test_schema_1.mx_table_1'::regclass, 1310023, 't'::"char", '-1288490189', '-429496731', false), ('mx_test_schema_1.mx_table_1'::regclass, 1310024, 't'::"char", '-429496730', '429496728', false), ('mx_test_schema_1.mx_table_1'::regclass, 1310025, 't'::"char", '429496729', '1288490187', false), ('mx_test_schema_1.mx_table_1'::regclass, 1310026, 't'::"char", '1288490188', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) FROM shard_data;
WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) AS (VALUES ('mx_test_schema_2.mx_table_2'::regclass, 1310027, 't'::"char", '-2147483648', '-1288490190', false), ('mx_test_schema_2.mx_table_2'::regclass, 1310028, 't'::"char", '-1288490189', '-429496731', false), ('mx_test_schema_2.mx_table_2'::regclass, 1310029, 't'::"char", '-429496730', '429496728', false), ('mx_test_schema_2.mx_table_2'::regclass, 1310030, 't'::"char", '429496729', '1288490187', false), ('mx_test_schema_2.mx_table_2'::regclass, 1310031, 't'::"char", '1288490188', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) FROM shard_data; WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) AS (VALUES ('mx_test_schema_2.mx_table_2'::regclass, 1310027, 't'::"char", '-2147483648', '-1288490190', false), ('mx_test_schema_2.mx_table_2'::regclass, 1310028, 't'::"char", '-1288490189', '-429496731', false), ('mx_test_schema_2.mx_table_2'::regclass, 1310029, 't'::"char", '-429496730', '429496728', false), ('mx_test_schema_2.mx_table_2'::regclass, 1310030, 't'::"char", '429496729', '1288490187', false), ('mx_test_schema_2.mx_table_2'::regclass, 1310031, 't'::"char", '1288490188', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) FROM shard_data;
WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) AS (VALUES ('mx_testing_schema.mx_test_table'::regclass, 1310000, 't'::"char", '-2147483648', '-1610612737', false), ('mx_testing_schema.mx_test_table'::regclass, 1310001, 't'::"char", '-1610612736', '-1073741825', false), ('mx_testing_schema.mx_test_table'::regclass, 1310002, 't'::"char", '-1073741824', '-536870913', false), ('mx_testing_schema.mx_test_table'::regclass, 1310003, 't'::"char", '-536870912', '-1', false), ('mx_testing_schema.mx_test_table'::regclass, 1310004, 't'::"char", '0', '536870911', false), ('mx_testing_schema.mx_test_table'::regclass, 1310005, 't'::"char", '536870912', '1073741823', false), ('mx_testing_schema.mx_test_table'::regclass, 1310006, 't'::"char", '1073741824', '1610612735', false), ('mx_testing_schema.mx_test_table'::regclass, 1310007, 't'::"char", '1610612736', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) FROM shard_data; WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) AS (VALUES ('mx_testing_schema.mx_test_table'::regclass, 1310000, 't'::"char", '-2147483648', '-1610612737', false), ('mx_testing_schema.mx_test_table'::regclass, 1310001, 't'::"char", '-1610612736', '-1073741825', false), ('mx_testing_schema.mx_test_table'::regclass, 1310002, 't'::"char", '-1073741824', '-536870913', false), ('mx_testing_schema.mx_test_table'::regclass, 1310003, 't'::"char", '-536870912', '-1', false), ('mx_testing_schema.mx_test_table'::regclass, 1310004, 't'::"char", '0', '536870911', false), ('mx_testing_schema.mx_test_table'::regclass, 1310005, 't'::"char", '536870912', '1073741823', false), ('mx_testing_schema.mx_test_table'::regclass, 1310006, 't'::"char", '1073741824', '1610612735', false), ('mx_testing_schema.mx_test_table'::regclass, 1310007, 't'::"char", '1610612736', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) FROM shard_data;
WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) AS (VALUES ('public.dist_table_1'::regclass, 1310076, 't'::"char", '-2147483648', '-1073741825', false), ('public.dist_table_1'::regclass, 1310077, 't'::"char", '-1073741824', '-1', false), ('public.dist_table_1'::regclass, 1310078, 't'::"char", '0', '1073741823', false), ('public.dist_table_1'::regclass, 1310079, 't'::"char", '1073741824', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) FROM shard_data; WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) AS (VALUES ('public.dist_table_1'::regclass, 1310076, 't'::"char", '-2147483648', '-1073741825', false), ('public.dist_table_1'::regclass, 1310077, 't'::"char", '-1073741824', '-1', false), ('public.dist_table_1'::regclass, 1310078, 't'::"char", '0', '1073741823', false), ('public.dist_table_1'::regclass, 1310079, 't'::"char", '1073741824', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) FROM shard_data;
WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) AS (VALUES ('public.mx_ref'::regclass, 1310075, 't'::"char", NULL, NULL, false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) FROM shard_data; WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) AS (VALUES ('public.mx_ref'::regclass, 1310075, 't'::"char", NULL, NULL, false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) FROM shard_data;
WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) AS (VALUES ('public.test_table'::regclass, 1310085, 't'::"char", '-2147483648', '-1073741825', false), ('public.test_table'::regclass, 1310086, 't'::"char", '-1073741824', '-1', false), ('public.test_table'::regclass, 1310087, 't'::"char", '0', '1073741823', false), ('public.test_table'::regclass, 1310088, 't'::"char", '1073741824', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) FROM shard_data; WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) AS (VALUES ('public.test_table'::regclass, 1310085, 't'::"char", '-2147483648', '-1073741825', false), ('public.test_table'::regclass, 1310086, 't'::"char", '-1073741824', '-1', false), ('public.test_table'::regclass, 1310087, 't'::"char", '0', '1073741823', false), ('public.test_table'::regclass, 1310088, 't'::"char", '1073741824', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) FROM shard_data;
(118 rows) (118 rows)
-- shouldn't work since test_table is MX -- shouldn't work since test_table is MX

View File

@ -194,8 +194,8 @@ SELECT unnest(activate_node_snapshot()) order by 1;
WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('table', ARRAY['public', 'single_shard_tbl']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data; WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('table', ARRAY['public', 'single_shard_tbl']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data;
WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310000, 0, 1, 100000), (1310001, 0, 2, 100001), (1310002, 0, 1, 100002), (1310003, 0, 2, 100003), (1310004, 0, 1, 100004), (1310005, 0, 2, 100005), (1310006, 0, 1, 100006), (1310007, 0, 2, 100007)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data; WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310000, 0, 1, 100000), (1310001, 0, 2, 100001), (1310002, 0, 1, 100002), (1310003, 0, 2, 100003), (1310004, 0, 1, 100004), (1310005, 0, 2, 100005), (1310006, 0, 1, 100006), (1310007, 0, 2, 100007)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data;
WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310008, 0, 2, 100008)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data; WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310008, 0, 2, 100008)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data;
WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) AS (VALUES ('public.mx_test_table'::regclass, 1310000, 't'::"char", '-2147483648', '-1610612737', false), ('public.mx_test_table'::regclass, 1310001, 't'::"char", '-1610612736', '-1073741825', false), ('public.mx_test_table'::regclass, 1310002, 't'::"char", '-1073741824', '-536870913', false), ('public.mx_test_table'::regclass, 1310003, 't'::"char", '-536870912', '-1', false), ('public.mx_test_table'::regclass, 1310004, 't'::"char", '0', '536870911', false), ('public.mx_test_table'::regclass, 1310005, 't'::"char", '536870912', '1073741823', false), ('public.mx_test_table'::regclass, 1310006, 't'::"char", '1073741824', '1610612735', false), ('public.mx_test_table'::regclass, 1310007, 't'::"char", '1610612736', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) FROM shard_data; WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) AS (VALUES ('public.mx_test_table'::regclass, 1310000, 't'::"char", '-2147483648', '-1610612737', false), ('public.mx_test_table'::regclass, 1310001, 't'::"char", '-1610612736', '-1073741825', false), ('public.mx_test_table'::regclass, 1310002, 't'::"char", '-1073741824', '-536870913', false), ('public.mx_test_table'::regclass, 1310003, 't'::"char", '-536870912', '-1', false), ('public.mx_test_table'::regclass, 1310004, 't'::"char", '0', '536870911', false), ('public.mx_test_table'::regclass, 1310005, 't'::"char", '536870912', '1073741823', false), ('public.mx_test_table'::regclass, 1310006, 't'::"char", '1073741824', '1610612735', false), ('public.mx_test_table'::regclass, 1310007, 't'::"char", '1610612736', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) FROM shard_data;
WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) AS (VALUES ('public.single_shard_tbl'::regclass, 1310008, 't'::"char", NULL, NULL, false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) FROM shard_data; WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) AS (VALUES ('public.single_shard_tbl'::regclass, 1310008, 't'::"char", NULL, NULL, false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) FROM shard_data;
(61 rows) (61 rows)
-- Drop single shard table -- Drop single shard table
@ -256,7 +256,7 @@ SELECT unnest(activate_node_snapshot()) order by 1;
WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('sequence', ARRAY['public', 'user_defined_seq']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data; WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('sequence', ARRAY['public', 'user_defined_seq']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data;
WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('table', ARRAY['public', 'mx_test_table']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data; WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('table', ARRAY['public', 'mx_test_table']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data;
WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310000, 0, 1, 100000), (1310001, 0, 2, 100001), (1310002, 0, 1, 100002), (1310003, 0, 2, 100003), (1310004, 0, 1, 100004), (1310005, 0, 2, 100005), (1310006, 0, 1, 100006), (1310007, 0, 2, 100007)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data; WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310000, 0, 1, 100000), (1310001, 0, 2, 100001), (1310002, 0, 1, 100002), (1310003, 0, 2, 100003), (1310004, 0, 1, 100004), (1310005, 0, 2, 100005), (1310006, 0, 1, 100006), (1310007, 0, 2, 100007)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data;
WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) AS (VALUES ('public.mx_test_table'::regclass, 1310000, 't'::"char", '-2147483648', '-1610612737', false), ('public.mx_test_table'::regclass, 1310001, 't'::"char", '-1610612736', '-1073741825', false), ('public.mx_test_table'::regclass, 1310002, 't'::"char", '-1073741824', '-536870913', false), ('public.mx_test_table'::regclass, 1310003, 't'::"char", '-536870912', '-1', false), ('public.mx_test_table'::regclass, 1310004, 't'::"char", '0', '536870911', false), ('public.mx_test_table'::regclass, 1310005, 't'::"char", '536870912', '1073741823', false), ('public.mx_test_table'::regclass, 1310006, 't'::"char", '1073741824', '1610612735', false), ('public.mx_test_table'::regclass, 1310007, 't'::"char", '1610612736', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) FROM shard_data; WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) AS (VALUES ('public.mx_test_table'::regclass, 1310000, 't'::"char", '-2147483648', '-1610612737', false), ('public.mx_test_table'::regclass, 1310001, 't'::"char", '-1610612736', '-1073741825', false), ('public.mx_test_table'::regclass, 1310002, 't'::"char", '-1073741824', '-536870913', false), ('public.mx_test_table'::regclass, 1310003, 't'::"char", '-536870912', '-1', false), ('public.mx_test_table'::regclass, 1310004, 't'::"char", '0', '536870911', false), ('public.mx_test_table'::regclass, 1310005, 't'::"char", '536870912', '1073741823', false), ('public.mx_test_table'::regclass, 1310006, 't'::"char", '1073741824', '1610612735', false), ('public.mx_test_table'::regclass, 1310007, 't'::"char", '1610612736', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) FROM shard_data;
(52 rows) (52 rows)
-- Show that schema changes are included in the activate node snapshot -- Show that schema changes are included in the activate node snapshot
@ -318,7 +318,7 @@ SELECT unnest(activate_node_snapshot()) order by 1;
WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('sequence', ARRAY['public', 'user_defined_seq']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data; WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('sequence', ARRAY['public', 'user_defined_seq']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data;
WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('table', ARRAY['mx_testing_schema', 'mx_test_table']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data; WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('table', ARRAY['mx_testing_schema', 'mx_test_table']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data;
WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310000, 0, 1, 100000), (1310001, 0, 2, 100001), (1310002, 0, 1, 100002), (1310003, 0, 2, 100003), (1310004, 0, 1, 100004), (1310005, 0, 2, 100005), (1310006, 0, 1, 100006), (1310007, 0, 2, 100007)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data; WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310000, 0, 1, 100000), (1310001, 0, 2, 100001), (1310002, 0, 1, 100002), (1310003, 0, 2, 100003), (1310004, 0, 1, 100004), (1310005, 0, 2, 100005), (1310006, 0, 1, 100006), (1310007, 0, 2, 100007)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data;
WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) AS (VALUES ('mx_testing_schema.mx_test_table'::regclass, 1310000, 't'::"char", '-2147483648', '-1610612737', false), ('mx_testing_schema.mx_test_table'::regclass, 1310001, 't'::"char", '-1610612736', '-1073741825', false), ('mx_testing_schema.mx_test_table'::regclass, 1310002, 't'::"char", '-1073741824', '-536870913', false), ('mx_testing_schema.mx_test_table'::regclass, 1310003, 't'::"char", '-536870912', '-1', false), ('mx_testing_schema.mx_test_table'::regclass, 1310004, 't'::"char", '0', '536870911', false), ('mx_testing_schema.mx_test_table'::regclass, 1310005, 't'::"char", '536870912', '1073741823', false), ('mx_testing_schema.mx_test_table'::regclass, 1310006, 't'::"char", '1073741824', '1610612735', false), ('mx_testing_schema.mx_test_table'::regclass, 1310007, 't'::"char", '1610612736', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) FROM shard_data; WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) AS (VALUES ('mx_testing_schema.mx_test_table'::regclass, 1310000, 't'::"char", '-2147483648', '-1610612737', false), ('mx_testing_schema.mx_test_table'::regclass, 1310001, 't'::"char", '-1610612736', '-1073741825', false), ('mx_testing_schema.mx_test_table'::regclass, 1310002, 't'::"char", '-1073741824', '-536870913', false), ('mx_testing_schema.mx_test_table'::regclass, 1310003, 't'::"char", '-536870912', '-1', false), ('mx_testing_schema.mx_test_table'::regclass, 1310004, 't'::"char", '0', '536870911', false), ('mx_testing_schema.mx_test_table'::regclass, 1310005, 't'::"char", '536870912', '1073741823', false), ('mx_testing_schema.mx_test_table'::regclass, 1310006, 't'::"char", '1073741824', '1610612735', false), ('mx_testing_schema.mx_test_table'::regclass, 1310007, 't'::"char", '1610612736', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) FROM shard_data;
(54 rows) (54 rows)
-- Show that append distributed tables are not included in the activate node snapshot -- Show that append distributed tables are not included in the activate node snapshot
@ -386,7 +386,7 @@ SELECT unnest(activate_node_snapshot()) order by 1;
WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('sequence', ARRAY['public', 'user_defined_seq']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data; WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('sequence', ARRAY['public', 'user_defined_seq']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data;
WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('table', ARRAY['mx_testing_schema', 'mx_test_table']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data; WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('table', ARRAY['mx_testing_schema', 'mx_test_table']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data;
WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310000, 0, 1, 100000), (1310001, 0, 2, 100001), (1310002, 0, 1, 100002), (1310003, 0, 2, 100003), (1310004, 0, 1, 100004), (1310005, 0, 2, 100005), (1310006, 0, 1, 100006), (1310007, 0, 2, 100007)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data; WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310000, 0, 1, 100000), (1310001, 0, 2, 100001), (1310002, 0, 1, 100002), (1310003, 0, 2, 100003), (1310004, 0, 1, 100004), (1310005, 0, 2, 100005), (1310006, 0, 1, 100006), (1310007, 0, 2, 100007)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data;
WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) AS (VALUES ('mx_testing_schema.mx_test_table'::regclass, 1310000, 't'::"char", '-2147483648', '-1610612737', false), ('mx_testing_schema.mx_test_table'::regclass, 1310001, 't'::"char", '-1610612736', '-1073741825', false), ('mx_testing_schema.mx_test_table'::regclass, 1310002, 't'::"char", '-1073741824', '-536870913', false), ('mx_testing_schema.mx_test_table'::regclass, 1310003, 't'::"char", '-536870912', '-1', false), ('mx_testing_schema.mx_test_table'::regclass, 1310004, 't'::"char", '0', '536870911', false), ('mx_testing_schema.mx_test_table'::regclass, 1310005, 't'::"char", '536870912', '1073741823', false), ('mx_testing_schema.mx_test_table'::regclass, 1310006, 't'::"char", '1073741824', '1610612735', false), ('mx_testing_schema.mx_test_table'::regclass, 1310007, 't'::"char", '1610612736', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) FROM shard_data; WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) AS (VALUES ('mx_testing_schema.mx_test_table'::regclass, 1310000, 't'::"char", '-2147483648', '-1610612737', false), ('mx_testing_schema.mx_test_table'::regclass, 1310001, 't'::"char", '-1610612736', '-1073741825', false), ('mx_testing_schema.mx_test_table'::regclass, 1310002, 't'::"char", '-1073741824', '-536870913', false), ('mx_testing_schema.mx_test_table'::regclass, 1310003, 't'::"char", '-536870912', '-1', false), ('mx_testing_schema.mx_test_table'::regclass, 1310004, 't'::"char", '0', '536870911', false), ('mx_testing_schema.mx_test_table'::regclass, 1310005, 't'::"char", '536870912', '1073741823', false), ('mx_testing_schema.mx_test_table'::regclass, 1310006, 't'::"char", '1073741824', '1610612735', false), ('mx_testing_schema.mx_test_table'::regclass, 1310007, 't'::"char", '1610612736', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) FROM shard_data;
(54 rows) (54 rows)
-- Show that range distributed tables are not included in the activate node snapshot -- Show that range distributed tables are not included in the activate node snapshot
@ -447,7 +447,7 @@ SELECT unnest(activate_node_snapshot()) order by 1;
WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('sequence', ARRAY['public', 'user_defined_seq']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data; WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('sequence', ARRAY['public', 'user_defined_seq']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data;
WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('table', ARRAY['mx_testing_schema', 'mx_test_table']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data; WITH distributed_object_data(typetext, objnames, objargs, distargumentindex, colocationid, force_delegation) AS (VALUES ('table', ARRAY['mx_testing_schema', 'mx_test_table']::text[], ARRAY[]::text[], -1, 0, false)) SELECT citus_internal_add_object_metadata(typetext, objnames, objargs, distargumentindex::int, colocationid::int, force_delegation::bool) FROM distributed_object_data;
WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310000, 0, 1, 100000), (1310001, 0, 2, 100001), (1310002, 0, 1, 100002), (1310003, 0, 2, 100003), (1310004, 0, 1, 100004), (1310005, 0, 2, 100005), (1310006, 0, 1, 100006), (1310007, 0, 2, 100007)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data; WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310000, 0, 1, 100000), (1310001, 0, 2, 100001), (1310002, 0, 1, 100002), (1310003, 0, 2, 100003), (1310004, 0, 1, 100004), (1310005, 0, 2, 100005), (1310006, 0, 1, 100006), (1310007, 0, 2, 100007)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data;
WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) AS (VALUES ('mx_testing_schema.mx_test_table'::regclass, 1310000, 't'::"char", '-2147483648', '-1610612737', false), ('mx_testing_schema.mx_test_table'::regclass, 1310001, 't'::"char", '-1610612736', '-1073741825', false), ('mx_testing_schema.mx_test_table'::regclass, 1310002, 't'::"char", '-1073741824', '-536870913', false), ('mx_testing_schema.mx_test_table'::regclass, 1310003, 't'::"char", '-536870912', '-1', false), ('mx_testing_schema.mx_test_table'::regclass, 1310004, 't'::"char", '0', '536870911', false), ('mx_testing_schema.mx_test_table'::regclass, 1310005, 't'::"char", '536870912', '1073741823', false), ('mx_testing_schema.mx_test_table'::regclass, 1310006, 't'::"char", '1073741824', '1610612735', false), ('mx_testing_schema.mx_test_table'::regclass, 1310007, 't'::"char", '1610612736', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) FROM shard_data; WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) AS (VALUES ('mx_testing_schema.mx_test_table'::regclass, 1310000, 't'::"char", '-2147483648', '-1610612737', false), ('mx_testing_schema.mx_test_table'::regclass, 1310001, 't'::"char", '-1610612736', '-1073741825', false), ('mx_testing_schema.mx_test_table'::regclass, 1310002, 't'::"char", '-1073741824', '-536870913', false), ('mx_testing_schema.mx_test_table'::regclass, 1310003, 't'::"char", '-536870912', '-1', false), ('mx_testing_schema.mx_test_table'::regclass, 1310004, 't'::"char", '0', '536870911', false), ('mx_testing_schema.mx_test_table'::regclass, 1310005, 't'::"char", '536870912', '1073741823', false), ('mx_testing_schema.mx_test_table'::regclass, 1310006, 't'::"char", '1073741824', '1610612735', false), ('mx_testing_schema.mx_test_table'::regclass, 1310007, 't'::"char", '1610612736', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) FROM shard_data;
(54 rows) (54 rows)
-- Test start_metadata_sync_to_node and citus_activate_node UDFs -- Test start_metadata_sync_to_node and citus_activate_node UDFs
@ -537,7 +537,7 @@ SELECT * FROM pg_dist_partition WHERE logicalrelid::text LIKE 'mx_testing_schema
(1 row) (1 row)
SELECT * FROM pg_dist_shard WHERE logicalrelid::text LIKE 'mx_testing_schema%' ORDER BY shardid; SELECT * FROM pg_dist_shard WHERE logicalrelid::text LIKE 'mx_testing_schema%' ORDER BY shardid;
logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsisolatednode logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsseparatenode
--------------------------------------------------------------------- ---------------------------------------------------------------------
mx_testing_schema.mx_test_table | 1310000 | t | -2147483648 | -1610612737 | f mx_testing_schema.mx_test_table | 1310000 | t | -2147483648 | -1610612737 | f
mx_testing_schema.mx_test_table | 1310001 | t | -1610612736 | -1073741825 | f mx_testing_schema.mx_test_table | 1310001 | t | -1610612736 | -1073741825 | f
@ -676,7 +676,7 @@ SELECT * FROM pg_dist_partition WHERE logicalrelid::text LIKE 'mx_testing_schema
(1 row) (1 row)
SELECT * FROM pg_dist_shard WHERE logicalrelid::text LIKE 'mx_testing_schema%' ORDER BY shardid; SELECT * FROM pg_dist_shard WHERE logicalrelid::text LIKE 'mx_testing_schema%' ORDER BY shardid;
logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsisolatednode logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsseparatenode
--------------------------------------------------------------------- ---------------------------------------------------------------------
mx_testing_schema.mx_test_table | 1310000 | t | -2147483648 | -1610612737 | f mx_testing_schema.mx_test_table | 1310000 | t | -2147483648 | -1610612737 | f
mx_testing_schema.mx_test_table | 1310001 | t | -1610612736 | -1073741825 | f mx_testing_schema.mx_test_table | 1310001 | t | -1610612736 | -1073741825 | f
@ -1021,7 +1021,7 @@ SELECT * FROM pg_dist_partition WHERE logicalrelid::text LIKE 'mx_test_schema%';
(0 rows) (0 rows)
SELECT * FROM pg_dist_shard WHERE logicalrelid::text LIKE 'mx_test_schema%'; SELECT * FROM pg_dist_shard WHERE logicalrelid::text LIKE 'mx_test_schema%';
logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsisolatednode logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsseparatenode
--------------------------------------------------------------------- ---------------------------------------------------------------------
(0 rows) (0 rows)
@ -1681,7 +1681,7 @@ SELECT "Column", "Type", "Definition" FROM index_attrs WHERE
relid = 'mx_ref_index'::regclass; relid = 'mx_ref_index'::regclass;
ERROR: relation "mx_ref_index" does not exist ERROR: relation "mx_ref_index" does not exist
SELECT * FROM pg_dist_shard WHERE shardid=:ref_table_shardid; SELECT * FROM pg_dist_shard WHERE shardid=:ref_table_shardid;
logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsisolatednode logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsseparatenode
--------------------------------------------------------------------- ---------------------------------------------------------------------
(0 rows) (0 rows)
@ -2056,12 +2056,12 @@ SELECT unnest(activate_node_snapshot()) order by 1;
WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310075, 0, 0, 100077), (1310075, 0, 1, 100078), (1310075, 0, 5, 100079)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data; WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310075, 0, 0, 100077), (1310075, 0, 1, 100078), (1310075, 0, 5, 100079)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data;
WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310076, 0, 1, 100080), (1310077, 0, 5, 100081), (1310078, 0, 1, 100082), (1310079, 0, 5, 100083)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data; WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310076, 0, 1, 100080), (1310077, 0, 5, 100081), (1310078, 0, 1, 100082), (1310079, 0, 5, 100083)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data;
WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310085, 0, 1, 100091), (1310086, 0, 5, 100092), (1310087, 0, 1, 100093), (1310088, 0, 5, 100094)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data; WITH placement_data(shardid, shardlength, groupid, placementid) AS (VALUES (1310085, 0, 1, 100091), (1310086, 0, 5, 100092), (1310087, 0, 1, 100093), (1310088, 0, 5, 100094)) SELECT citus_internal_add_placement_metadata(shardid, shardlength, groupid, placementid) FROM placement_data;
WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) AS (VALUES ('mx_test_schema_1.mx_table_1'::regclass, 1310022, 't'::"char", '-2147483648', '-1288490190', false), ('mx_test_schema_1.mx_table_1'::regclass, 1310023, 't'::"char", '-1288490189', '-429496731', false), ('mx_test_schema_1.mx_table_1'::regclass, 1310024, 't'::"char", '-429496730', '429496728', false), ('mx_test_schema_1.mx_table_1'::regclass, 1310025, 't'::"char", '429496729', '1288490187', false), ('mx_test_schema_1.mx_table_1'::regclass, 1310026, 't'::"char", '1288490188', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) FROM shard_data; WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) AS (VALUES ('mx_test_schema_1.mx_table_1'::regclass, 1310022, 't'::"char", '-2147483648', '-1288490190', false), ('mx_test_schema_1.mx_table_1'::regclass, 1310023, 't'::"char", '-1288490189', '-429496731', false), ('mx_test_schema_1.mx_table_1'::regclass, 1310024, 't'::"char", '-429496730', '429496728', false), ('mx_test_schema_1.mx_table_1'::regclass, 1310025, 't'::"char", '429496729', '1288490187', false), ('mx_test_schema_1.mx_table_1'::regclass, 1310026, 't'::"char", '1288490188', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) FROM shard_data;
WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) AS (VALUES ('mx_test_schema_2.mx_table_2'::regclass, 1310027, 't'::"char", '-2147483648', '-1288490190', false), ('mx_test_schema_2.mx_table_2'::regclass, 1310028, 't'::"char", '-1288490189', '-429496731', false), ('mx_test_schema_2.mx_table_2'::regclass, 1310029, 't'::"char", '-429496730', '429496728', false), ('mx_test_schema_2.mx_table_2'::regclass, 1310030, 't'::"char", '429496729', '1288490187', false), ('mx_test_schema_2.mx_table_2'::regclass, 1310031, 't'::"char", '1288490188', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) FROM shard_data; WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) AS (VALUES ('mx_test_schema_2.mx_table_2'::regclass, 1310027, 't'::"char", '-2147483648', '-1288490190', false), ('mx_test_schema_2.mx_table_2'::regclass, 1310028, 't'::"char", '-1288490189', '-429496731', false), ('mx_test_schema_2.mx_table_2'::regclass, 1310029, 't'::"char", '-429496730', '429496728', false), ('mx_test_schema_2.mx_table_2'::regclass, 1310030, 't'::"char", '429496729', '1288490187', false), ('mx_test_schema_2.mx_table_2'::regclass, 1310031, 't'::"char", '1288490188', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) FROM shard_data;
WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) AS (VALUES ('mx_testing_schema.mx_test_table'::regclass, 1310000, 't'::"char", '-2147483648', '-1610612737', false), ('mx_testing_schema.mx_test_table'::regclass, 1310001, 't'::"char", '-1610612736', '-1073741825', false), ('mx_testing_schema.mx_test_table'::regclass, 1310002, 't'::"char", '-1073741824', '-536870913', false), ('mx_testing_schema.mx_test_table'::regclass, 1310003, 't'::"char", '-536870912', '-1', false), ('mx_testing_schema.mx_test_table'::regclass, 1310004, 't'::"char", '0', '536870911', false), ('mx_testing_schema.mx_test_table'::regclass, 1310005, 't'::"char", '536870912', '1073741823', false), ('mx_testing_schema.mx_test_table'::regclass, 1310006, 't'::"char", '1073741824', '1610612735', false), ('mx_testing_schema.mx_test_table'::regclass, 1310007, 't'::"char", '1610612736', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) FROM shard_data; WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) AS (VALUES ('mx_testing_schema.mx_test_table'::regclass, 1310000, 't'::"char", '-2147483648', '-1610612737', false), ('mx_testing_schema.mx_test_table'::regclass, 1310001, 't'::"char", '-1610612736', '-1073741825', false), ('mx_testing_schema.mx_test_table'::regclass, 1310002, 't'::"char", '-1073741824', '-536870913', false), ('mx_testing_schema.mx_test_table'::regclass, 1310003, 't'::"char", '-536870912', '-1', false), ('mx_testing_schema.mx_test_table'::regclass, 1310004, 't'::"char", '0', '536870911', false), ('mx_testing_schema.mx_test_table'::regclass, 1310005, 't'::"char", '536870912', '1073741823', false), ('mx_testing_schema.mx_test_table'::regclass, 1310006, 't'::"char", '1073741824', '1610612735', false), ('mx_testing_schema.mx_test_table'::regclass, 1310007, 't'::"char", '1610612736', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) FROM shard_data;
WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) AS (VALUES ('public.dist_table_1'::regclass, 1310076, 't'::"char", '-2147483648', '-1073741825', false), ('public.dist_table_1'::regclass, 1310077, 't'::"char", '-1073741824', '-1', false), ('public.dist_table_1'::regclass, 1310078, 't'::"char", '0', '1073741823', false), ('public.dist_table_1'::regclass, 1310079, 't'::"char", '1073741824', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) FROM shard_data; WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) AS (VALUES ('public.dist_table_1'::regclass, 1310076, 't'::"char", '-2147483648', '-1073741825', false), ('public.dist_table_1'::regclass, 1310077, 't'::"char", '-1073741824', '-1', false), ('public.dist_table_1'::regclass, 1310078, 't'::"char", '0', '1073741823', false), ('public.dist_table_1'::regclass, 1310079, 't'::"char", '1073741824', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) FROM shard_data;
WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) AS (VALUES ('public.mx_ref'::regclass, 1310075, 't'::"char", NULL, NULL, false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) FROM shard_data; WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) AS (VALUES ('public.mx_ref'::regclass, 1310075, 't'::"char", NULL, NULL, false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) FROM shard_data;
WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) AS (VALUES ('public.test_table'::regclass, 1310085, 't'::"char", '-2147483648', '-1073741825', false), ('public.test_table'::regclass, 1310086, 't'::"char", '-1073741824', '-1', false), ('public.test_table'::regclass, 1310087, 't'::"char", '0', '1073741823', false), ('public.test_table'::regclass, 1310088, 't'::"char", '1073741824', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsisolatednode) FROM shard_data; WITH shard_data(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) AS (VALUES ('public.test_table'::regclass, 1310085, 't'::"char", '-2147483648', '-1073741825', false), ('public.test_table'::regclass, 1310086, 't'::"char", '-1073741824', '-1', false), ('public.test_table'::regclass, 1310087, 't'::"char", '0', '1073741823', false), ('public.test_table'::regclass, 1310088, 't'::"char", '1073741824', '2147483647', false)) SELECT citus_internal_add_shard_metadata(relationname, shardid, storagetype, shardminvalue, shardmaxvalue, needsseparatenode) FROM shard_data;
(118 rows) (118 rows)
-- shouldn't work since test_table is MX -- shouldn't work since test_table is MX

View File

@ -12,7 +12,7 @@ SELECT create_distributed_table('source_table_xyz', 'key', 'range');
CALL public.create_range_partitioned_shards('source_table_xyz', '{"(0,a)","(25,z)"}','{"(24,a)","(49,z)"}'); CALL public.create_range_partitioned_shards('source_table_xyz', '{"(0,a)","(25,z)"}','{"(24,a)","(49,z)"}');
SELECT * FROM pg_dist_shard WHERE logicalrelid='source_table_xyz'::regclass::oid ORDER BY shardid; SELECT * FROM pg_dist_shard WHERE logicalrelid='source_table_xyz'::regclass::oid ORDER BY shardid;
logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsisolatednode logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsseparatenode
--------------------------------------------------------------------- ---------------------------------------------------------------------
source_table_xyz | 4213581 | t | (0,a) | (24,a) | f source_table_xyz | 4213581 | t | (0,a) | (24,a) | f
source_table_xyz | 4213582 | t | (25,z) | (49,z) | f source_table_xyz | 4213582 | t | (25,z) | (49,z) | f

View File

@ -65,7 +65,7 @@ SELECT * FROM pg_dist_partition;
(0 rows) (0 rows)
SELECT * FROM pg_dist_shard; SELECT * FROM pg_dist_shard;
logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsisolatednode logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsseparatenode
--------------------------------------------------------------------- ---------------------------------------------------------------------
(0 rows) (0 rows)

View File

@ -168,7 +168,7 @@ SELECT count(*) FROM orders_streaming WHERE o_orderkey = 103;
SELECT * FROM pg_dist_shard SELECT * FROM pg_dist_shard
WHERE logicalrelid = 'lineitem_streaming'::regclass OR logicalrelid = 'orders_streaming'::regclass WHERE logicalrelid = 'lineitem_streaming'::regclass OR logicalrelid = 'orders_streaming'::regclass
ORDER BY shardminvalue::BIGINT, logicalrelid; ORDER BY shardminvalue::BIGINT, logicalrelid;
logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsisolatednode logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsseparatenode
--------------------------------------------------------------------- ---------------------------------------------------------------------
lineitem_streaming | 1230000 | t | -2147483648 | -1 | f lineitem_streaming | 1230000 | t | -2147483648 | -1 | f
orders_streaming | 1230002 | t | -2147483648 | -1 | f orders_streaming | 1230002 | t | -2147483648 | -1 | f
@ -387,7 +387,7 @@ SELECT count(*) FROM orders_streaming WHERE o_orderkey = 103;
SELECT * FROM pg_dist_shard SELECT * FROM pg_dist_shard
WHERE logicalrelid = 'lineitem_streaming'::regclass OR logicalrelid = 'orders_streaming'::regclass WHERE logicalrelid = 'lineitem_streaming'::regclass OR logicalrelid = 'orders_streaming'::regclass
ORDER BY shardminvalue::BIGINT, logicalrelid; ORDER BY shardminvalue::BIGINT, logicalrelid;
logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsisolatednode logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsseparatenode
--------------------------------------------------------------------- ---------------------------------------------------------------------
lineitem_streaming | 1230040 | t | -2147483648 | -2147483648 | f lineitem_streaming | 1230040 | t | -2147483648 | -2147483648 | f
orders_streaming | 1230042 | t | -2147483648 | -2147483648 | f orders_streaming | 1230042 | t | -2147483648 | -2147483648 | f
@ -541,7 +541,7 @@ SET search_path to "Tenant Isolation";
SELECT * FROM pg_dist_shard SELECT * FROM pg_dist_shard
WHERE logicalrelid = 'lineitem_streaming'::regclass OR logicalrelid = 'orders_streaming'::regclass WHERE logicalrelid = 'lineitem_streaming'::regclass OR logicalrelid = 'orders_streaming'::regclass
ORDER BY shardminvalue::BIGINT, logicalrelid; ORDER BY shardminvalue::BIGINT, logicalrelid;
logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsisolatednode logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsseparatenode
--------------------------------------------------------------------- ---------------------------------------------------------------------
lineitem_streaming | 1230040 | t | -2147483648 | -2147483648 | f lineitem_streaming | 1230040 | t | -2147483648 | -2147483648 | f
orders_streaming | 1230042 | t | -2147483648 | -2147483648 | f orders_streaming | 1230042 | t | -2147483648 | -2147483648 | f
@ -684,7 +684,7 @@ ERROR: cannot isolate tenant because tenant isolation is only support for hash
SELECT * FROM pg_dist_shard SELECT * FROM pg_dist_shard
WHERE logicalrelid = 'lineitem_streaming'::regclass OR logicalrelid = 'orders_streaming'::regclass WHERE logicalrelid = 'lineitem_streaming'::regclass OR logicalrelid = 'orders_streaming'::regclass
ORDER BY shardminvalue::BIGINT, logicalrelid; ORDER BY shardminvalue::BIGINT, logicalrelid;
logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsisolatednode logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsseparatenode
--------------------------------------------------------------------- ---------------------------------------------------------------------
lineitem_streaming | 1230040 | t | -2147483648 | -2147483648 | f lineitem_streaming | 1230040 | t | -2147483648 | -2147483648 | f
orders_streaming | 1230042 | t | -2147483648 | -2147483648 | f orders_streaming | 1230042 | t | -2147483648 | -2147483648 | f

View File

@ -168,7 +168,7 @@ SELECT count(*) FROM orders_streaming WHERE o_orderkey = 103;
SELECT * FROM pg_dist_shard SELECT * FROM pg_dist_shard
WHERE logicalrelid = 'lineitem_streaming'::regclass OR logicalrelid = 'orders_streaming'::regclass WHERE logicalrelid = 'lineitem_streaming'::regclass OR logicalrelid = 'orders_streaming'::regclass
ORDER BY shardminvalue::BIGINT, logicalrelid; ORDER BY shardminvalue::BIGINT, logicalrelid;
logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsisolatednode logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsseparatenode
--------------------------------------------------------------------- ---------------------------------------------------------------------
lineitem_streaming | 1230000 | t | -2147483648 | -1 | f lineitem_streaming | 1230000 | t | -2147483648 | -1 | f
orders_streaming | 1230002 | t | -2147483648 | -1 | f orders_streaming | 1230002 | t | -2147483648 | -1 | f
@ -399,7 +399,7 @@ SELECT count(*) FROM orders_streaming WHERE o_orderkey = 103;
SELECT * FROM pg_dist_shard SELECT * FROM pg_dist_shard
WHERE logicalrelid = 'lineitem_streaming'::regclass OR logicalrelid = 'orders_streaming'::regclass WHERE logicalrelid = 'lineitem_streaming'::regclass OR logicalrelid = 'orders_streaming'::regclass
ORDER BY shardminvalue::BIGINT, logicalrelid; ORDER BY shardminvalue::BIGINT, logicalrelid;
logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsisolatednode logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsseparatenode
--------------------------------------------------------------------- ---------------------------------------------------------------------
lineitem_streaming | 1230040 | t | -2147483648 | -2147483648 | f lineitem_streaming | 1230040 | t | -2147483648 | -2147483648 | f
orders_streaming | 1230042 | t | -2147483648 | -2147483648 | f orders_streaming | 1230042 | t | -2147483648 | -2147483648 | f
@ -553,7 +553,7 @@ SET search_path to "Tenant Isolation";
SELECT * FROM pg_dist_shard SELECT * FROM pg_dist_shard
WHERE logicalrelid = 'lineitem_streaming'::regclass OR logicalrelid = 'orders_streaming'::regclass WHERE logicalrelid = 'lineitem_streaming'::regclass OR logicalrelid = 'orders_streaming'::regclass
ORDER BY shardminvalue::BIGINT, logicalrelid; ORDER BY shardminvalue::BIGINT, logicalrelid;
logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsisolatednode logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsseparatenode
--------------------------------------------------------------------- ---------------------------------------------------------------------
lineitem_streaming | 1230040 | t | -2147483648 | -2147483648 | f lineitem_streaming | 1230040 | t | -2147483648 | -2147483648 | f
orders_streaming | 1230042 | t | -2147483648 | -2147483648 | f orders_streaming | 1230042 | t | -2147483648 | -2147483648 | f
@ -728,7 +728,7 @@ ERROR: cannot isolate tenant because tenant isolation is only support for hash
SELECT * FROM pg_dist_shard SELECT * FROM pg_dist_shard
WHERE logicalrelid = 'lineitem_streaming'::regclass OR logicalrelid = 'orders_streaming'::regclass WHERE logicalrelid = 'lineitem_streaming'::regclass OR logicalrelid = 'orders_streaming'::regclass
ORDER BY shardminvalue::BIGINT, logicalrelid; ORDER BY shardminvalue::BIGINT, logicalrelid;
logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsisolatednode logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue | needsseparatenode
--------------------------------------------------------------------- ---------------------------------------------------------------------
lineitem_streaming | 1230040 | t | -2147483648 | -2147483648 | f lineitem_streaming | 1230040 | t | -2147483648 | -2147483648 | f
orders_streaming | 1230042 | t | -2147483648 | -2147483648 | f orders_streaming | 1230042 | t | -2147483648 | -2147483648 | f

View File

@ -547,7 +547,7 @@ AS $func$
END; END;
$func$ LANGUAGE plpgsql; $func$ LANGUAGE plpgsql;
-- Takes a table name and returns a json object for each shard group that -- Takes a table name and returns a json object for each shard group that
-- contains a shard whose placements need isolation. -- contains a shard whose placements need separate nodes.
-- --
-- This does not only return the shards of input relation but also considers -- This does not only return the shards of input relation but also considers
-- all colocated relations. -- all colocated relations.
@ -562,7 +562,7 @@ $func$ LANGUAGE plpgsql;
-- It only returned shard groups 10 and 15 because they are the only shard groups -- It only returned shard groups 10 and 15 because they are the only shard groups
-- that contain at least one shard whose placements need an isolation. -- that contain at least one shard whose placements need an isolation.
-- --
-- (Innermost) Boolean values represent needsisolatednode value for given -- (Innermost) Boolean values represent needsseparatenode value for given
-- shard. For example, -- shard. For example,
-- --
-- {"15": [{"dist_1": false},{"dist_3": true}]} -- {"15": [{"dist_1": false},{"dist_3": true}]}
@ -576,22 +576,22 @@ RETURNS SETOF jsonb AS $func$
RETURN QUERY RETURN QUERY
SELECT SELECT
COALESCE( COALESCE(
jsonb_agg(jsonb_build_object(shardgroupindex, needsisolatednodejson) ORDER BY shardgroupindex), jsonb_agg(jsonb_build_object(shardgroupindex, needsseparatenodejson) ORDER BY shardgroupindex),
'{}'::jsonb '{}'::jsonb
) AS result ) AS result
FROM ( FROM (
SELECT shardgroupindex, SELECT shardgroupindex,
jsonb_agg(jsonb_build_object(logicalrelid, needsisolatednode) ORDER BY logicalrelid::text) AS needsisolatednodejson jsonb_agg(jsonb_build_object(logicalrelid, needsseparatenode) ORDER BY logicalrelid::text) AS needsseparatenodejson
FROM ( FROM (
SELECT shardgroupindex, SELECT shardgroupindex,
logicalrelid, logicalrelid,
needsisolatednode needsseparatenode
FROM public.get_enumerated_shard_groups(qualified_table_name) AS shardgroups FROM public.get_enumerated_shard_groups(qualified_table_name) AS shardgroups
JOIN pg_dist_shard JOIN pg_dist_shard
ON shardid = ANY(shardids) ON shardid = ANY(shardids)
) q1 ) q1
GROUP BY shardgroupindex GROUP BY shardgroupindex
) q2 ) q2
WHERE needsisolatednodejson::text LIKE '%true%'; WHERE needsseparatenodejson::text LIKE '%true%';
END; END;
$func$ LANGUAGE plpgsql; $func$ LANGUAGE plpgsql;

View File

@ -81,7 +81,7 @@ ORDER BY 1;
function citus_internal_is_replication_origin_tracking_active() function citus_internal_is_replication_origin_tracking_active()
function citus_internal_local_blocked_processes() function citus_internal_local_blocked_processes()
function citus_internal_mark_node_not_synced(integer,integer) function citus_internal_mark_node_not_synced(integer,integer)
function citus_internal_shard_group_set_needsisolatednode(bigint,boolean) function citus_internal_shard_group_set_needsseparatenode(bigint,boolean)
function citus_internal_start_replication_origin_tracking() function citus_internal_start_replication_origin_tracking()
function citus_internal_stop_replication_origin_tracking() function citus_internal_stop_replication_origin_tracking()
function citus_internal_unregister_tenant_schema_globally(oid,text) function citus_internal_unregister_tenant_schema_globally(oid,text)

View File

@ -34,8 +34,8 @@ CREATE SCHEMA isolate_placement;
SET search_path TO isolate_placement; SET search_path TO isolate_placement;
-- test null input -- test null input
SELECT citus_internal_shard_group_set_needsisolatednode(0, NULL); SELECT citus_internal_shard_group_set_needsseparatenode(0, NULL);
SELECT citus_internal_shard_group_set_needsisolatednode(NULL, false); SELECT citus_internal_shard_group_set_needsseparatenode(NULL, false);
SET citus.shard_replication_factor TO 1; SET citus.shard_replication_factor TO 1;
SET citus.next_shard_id TO 2000000; SET citus.next_shard_id TO 2000000;
@ -44,7 +44,7 @@ CREATE TABLE single_shard_1(a int);
SELECT create_distributed_table('single_shard_1', null, colocate_with=>'none'); SELECT create_distributed_table('single_shard_1', null, colocate_with=>'none');
-- test with user that doesn't have permission to execute the function -- test with user that doesn't have permission to execute the function
SELECT citus_internal_shard_group_set_needsisolatednode(shardid, true) FROM pg_dist_shard WHERE logicalrelid = 'isolate_placement.single_shard_1'::regclass; SELECT citus_internal_shard_group_set_needsseparatenode(shardid, true) FROM pg_dist_shard WHERE logicalrelid = 'isolate_placement.single_shard_1'::regclass;
DROP TABLE single_shard_1; DROP TABLE single_shard_1;
@ -56,16 +56,16 @@ SELECT pg_sleep(0.1);
SET ROLE test_user_isolate_placement; SET ROLE test_user_isolate_placement;
-- test invalid shard id -- test invalid shard id
SELECT citus_internal_shard_group_set_needsisolatednode(0, true); SELECT citus_internal_shard_group_set_needsseparatenode(0, true);
-- test null needs_isolated_node -- test null needs_separate_node
SELECT citus_internal_add_shard_metadata( SELECT citus_internal_add_shard_metadata(
relation_id=>0, relation_id=>0,
shard_id=>0, shard_id=>0,
storage_type=>'0', storage_type=>'0',
shard_min_value=>'0', shard_min_value=>'0',
shard_max_value=>'0', shard_max_value=>'0',
needs_isolated_node=>null); needs_separate_node=>null);
RESET ROLE; RESET ROLE;
REVOKE ALL ON SCHEMA isolate_placement FROM test_user_isolate_placement; REVOKE ALL ON SCHEMA isolate_placement FROM test_user_isolate_placement;
@ -95,7 +95,7 @@ SET ROLE regularuser;
-- throws an error as the user is not the owner of the table -- throws an error as the user is not the owner of the table
SELECT citus_shard_property_set(shardid) FROM pg_dist_shard WHERE logicalrelid = 'isolate_placement.single_shard_1'::regclass; SELECT citus_shard_property_set(shardid) FROM pg_dist_shard WHERE logicalrelid = 'isolate_placement.single_shard_1'::regclass;
SELECT citus_shard_property_set(shardid, anti_affinity=>true) FROM pg_dist_shard WHERE logicalrelid = 'isolate_placement.single_shard_1'::regclass; SELECT citus_shard_property_set(shardid, anti_affinity=>true) FROM pg_dist_shard WHERE logicalrelid = 'isolate_placement.single_shard_1'::regclass;
SELECT citus_internal_shard_group_set_needsisolatednode(shardid, true) FROM pg_dist_shard WHERE logicalrelid = 'isolate_placement.single_shard_1'::regclass; SELECT citus_internal_shard_group_set_needsseparatenode(shardid, true) FROM pg_dist_shard WHERE logicalrelid = 'isolate_placement.single_shard_1'::regclass;
-- assign all tables to regularuser -- assign all tables to regularuser
RESET ROLE; RESET ROLE;
@ -110,14 +110,14 @@ SELECT result FROM run_command_on_all_nodes($$
$$) $$)
ORDER BY result; ORDER BY result;
SELECT citus_internal_shard_group_set_needsisolatednode(shardid, false) FROM pg_dist_shard WHERE logicalrelid = 'isolate_placement.single_shard_1'::regclass; SELECT citus_internal_shard_group_set_needsseparatenode(shardid, false) FROM pg_dist_shard WHERE logicalrelid = 'isolate_placement.single_shard_1'::regclass;
SELECT result FROM run_command_on_all_nodes($$ SELECT result FROM run_command_on_all_nodes($$
SELECT * FROM public.get_colocated_shards_needisolatednode('isolate_placement.single_shard_1') SELECT * FROM public.get_colocated_shards_needisolatednode('isolate_placement.single_shard_1')
$$) $$)
ORDER BY result; ORDER BY result;
SELECT citus_internal_shard_group_set_needsisolatednode(shardid, true) FROM pg_dist_shard WHERE logicalrelid = 'isolate_placement.single_shard_1'::regclass; SELECT citus_internal_shard_group_set_needsseparatenode(shardid, true) FROM pg_dist_shard WHERE logicalrelid = 'isolate_placement.single_shard_1'::regclass;
DROP TABLE single_shard_1; DROP TABLE single_shard_1;
RESET ROLE; RESET ROLE;
@ -148,7 +148,7 @@ SELECT create_distributed_table('dist_3', 'a', colocate_with=>'dist_1');
SET citus.shard_replication_factor TO 1; SET citus.shard_replication_factor TO 1;
-- none of the placements have been marked as needsisolatednode yet -- none of the placements have been marked as needsseparatenode yet
SELECT result FROM run_command_on_all_nodes($$ SELECT result FROM run_command_on_all_nodes($$
SELECT * FROM public.get_colocated_shards_needisolatednode('isolate_placement.dist_1') SELECT * FROM public.get_colocated_shards_needisolatednode('isolate_placement.dist_1')
$$) $$)
@ -239,7 +239,7 @@ CREATE TABLE dist_4_concurrently(a int);
SELECT create_distributed_table_concurrently('dist_4_concurrently', 'a', colocate_with=>'dist_1'); SELECT create_distributed_table_concurrently('dist_4_concurrently', 'a', colocate_with=>'dist_1');
-- Placements of a new distributed table created within the same colocated -- Placements of a new distributed table created within the same colocated
-- group inherit needsisolatednode from the colocated placements too. -- group inherit needsseparatenode from the colocated placements too.
SELECT result FROM run_command_on_all_nodes($$ SELECT result FROM run_command_on_all_nodes($$
SELECT * FROM public.get_colocated_shards_needisolatednode('isolate_placement.dist_1') SELECT * FROM public.get_colocated_shards_needisolatednode('isolate_placement.dist_1')
$$) $$)
@ -368,7 +368,7 @@ FROM pg_dist_shard
WHERE shardid = :shardgroup_9_shardid; WHERE shardid = :shardgroup_9_shardid;
-- We shouldn't see shard group 9 because shard-split operation doesn't -- We shouldn't see shard group 9 because shard-split operation doesn't
-- preserve needsisolatednode flag when splitting the shard. -- preserve needsseparatenode flag when splitting the shard.
SELECT result FROM run_command_on_all_nodes($$ SELECT result FROM run_command_on_all_nodes($$
SELECT * FROM public.get_colocated_shards_needisolatednode('isolate_placement.dist_1') SELECT * FROM public.get_colocated_shards_needisolatednode('isolate_placement.dist_1')
$$) $$)
@ -424,7 +424,7 @@ select get_shard_id_for_distribution_column('dist_3', 100) = :shardgroup_17_shar
SELECT 1 FROM isolate_tenant_to_new_shard('dist_3', 100, shard_transfer_mode => 'block_writes'); SELECT 1 FROM isolate_tenant_to_new_shard('dist_3', 100, shard_transfer_mode => 'block_writes');
-- We shouldn't see shard group 17 because isolate_tenant_to_new_shard doesn't -- We shouldn't see shard group 17 because isolate_tenant_to_new_shard doesn't
-- preserve needsisolatednode flag when splitting the shard. -- preserve needsseparatenode flag when splitting the shard.
SELECT result FROM run_command_on_all_nodes($$ SELECT result FROM run_command_on_all_nodes($$
SELECT * FROM public.get_colocated_shards_needisolatednode('isolate_placement.dist_3') SELECT * FROM public.get_colocated_shards_needisolatednode('isolate_placement.dist_3')
$$) $$)

View File

@ -575,7 +575,7 @@ $func$ LANGUAGE plpgsql;
-- Takes a table name and returns a json object for each shard group that -- Takes a table name and returns a json object for each shard group that
-- contains a shard whose placements need isolation. -- contains a shard whose placements need separate nodes.
-- --
-- This does not only return the shards of input relation but also considers -- This does not only return the shards of input relation but also considers
-- all colocated relations. -- all colocated relations.
@ -590,7 +590,7 @@ $func$ LANGUAGE plpgsql;
-- It only returned shard groups 10 and 15 because they are the only shard groups -- It only returned shard groups 10 and 15 because they are the only shard groups
-- that contain at least one shard whose placements need an isolation. -- that contain at least one shard whose placements need an isolation.
-- --
-- (Innermost) Boolean values represent needsisolatednode value for given -- (Innermost) Boolean values represent needsseparatenode value for given
-- shard. For example, -- shard. For example,
-- --
-- {"15": [{"dist_1": false},{"dist_3": true}]} -- {"15": [{"dist_1": false},{"dist_3": true}]}
@ -604,22 +604,22 @@ RETURNS SETOF jsonb AS $func$
RETURN QUERY RETURN QUERY
SELECT SELECT
COALESCE( COALESCE(
jsonb_agg(jsonb_build_object(shardgroupindex, needsisolatednodejson) ORDER BY shardgroupindex), jsonb_agg(jsonb_build_object(shardgroupindex, needsseparatenodejson) ORDER BY shardgroupindex),
'{}'::jsonb '{}'::jsonb
) AS result ) AS result
FROM ( FROM (
SELECT shardgroupindex, SELECT shardgroupindex,
jsonb_agg(jsonb_build_object(logicalrelid, needsisolatednode) ORDER BY logicalrelid::text) AS needsisolatednodejson jsonb_agg(jsonb_build_object(logicalrelid, needsseparatenode) ORDER BY logicalrelid::text) AS needsseparatenodejson
FROM ( FROM (
SELECT shardgroupindex, SELECT shardgroupindex,
logicalrelid, logicalrelid,
needsisolatednode needsseparatenode
FROM public.get_enumerated_shard_groups(qualified_table_name) AS shardgroups FROM public.get_enumerated_shard_groups(qualified_table_name) AS shardgroups
JOIN pg_dist_shard JOIN pg_dist_shard
ON shardid = ANY(shardids) ON shardid = ANY(shardids)
) q1 ) q1
GROUP BY shardgroupindex GROUP BY shardgroupindex
) q2 ) q2
WHERE needsisolatednodejson::text LIKE '%true%'; WHERE needsseparatenodejson::text LIKE '%true%';
END; END;
$func$ LANGUAGE plpgsql; $func$ LANGUAGE plpgsql;