improve code and one more test

tenant-schema-isolation-complete-view
Onur Tirtir 2023-09-26 18:10:50 +03:00
parent 83dd504a64
commit 3b767211cc
3 changed files with 26 additions and 8 deletions

View File

@ -572,14 +572,6 @@ CreateDistributedTableConcurrently(Oid relationId, char *distributionColumnName,
colocatedTableId = ColocatedTableId(colocationId); colocatedTableId = ColocatedTableId(colocationId);
} }
List *workerNodeList = NewDistributedTablePlacementNodeList(NoLock);
if (workerNodeList == NIL)
{
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("no worker nodes are available for placing shards"),
errhint("Add more worker nodes.")));
}
List *workersForPlacementList; List *workersForPlacementList;
List *shardSplitPointsList; List *shardSplitPointsList;
List *needsIsolatedNodeForPlacementList; List *needsIsolatedNodeForPlacementList;
@ -615,6 +607,14 @@ CreateDistributedTableConcurrently(Oid relationId, char *distributionColumnName,
/* /*
* Place shards in a round-robin fashion across all data nodes. * Place shards in a round-robin fashion across all data nodes.
*/ */
List *workerNodeList = NewDistributedTablePlacementNodeList(NoLock);
if (workerNodeList == NIL)
{
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("no worker nodes are available for placing shards"),
errhint("Add more worker nodes.")));
}
workersForPlacementList = RoundRobinWorkerNodeList(workerNodeList, shardCount); workersForPlacementList = RoundRobinWorkerNodeList(workerNodeList, shardCount);
/* /*

View File

@ -36,6 +36,15 @@ 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_needsisolatednode(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
SELECT citus_internal_add_shard_metadata(
relation_id=>0,
shard_id=>0,
storage_type=>'0',
shard_min_value=>'0',
shard_max_value=>'0',
needs_isolated_node=>null);
ERROR: needs isolated 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;

View File

@ -29,6 +29,15 @@ 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_needsisolatednode(0, true);
-- test null needs_isolated_node
SELECT citus_internal_add_shard_metadata(
relation_id=>0,
shard_id=>0,
storage_type=>'0',
shard_min_value=>'0',
shard_max_value=>'0',
needs_isolated_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;
DROP USER test_user_isolate_placement; DROP USER test_user_isolate_placement;