-
Notifications
You must be signed in to change notification settings - Fork 486
[server] support database level buckets limit #2126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
caozhen1937
wants to merge
3
commits into
apache:main
Choose a base branch
from
caozhen1937:FLUSS_ISSUE_1993
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1372,7 +1372,7 @@ tablePath, newPartitionSpec("age", "4"), false) | |
| .get()) | ||
| .cause() | ||
| .isInstanceOf(TooManyBucketsException.class) | ||
| .hasMessageContaining("exceeding the maximum of 30 buckets"); | ||
| .hasMessageContaining("exceeding the database-level maximum of 30 buckets"); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -1403,7 +1403,169 @@ public void testBucketLimitForNonPartitionedTable() throws Exception { | |
| assertThatThrownBy(() -> admin.createTable(tablePath, nonPartitionedTable, false).get()) | ||
| .cause() | ||
| .isInstanceOf(TooManyBucketsException.class) | ||
| .hasMessageContaining("exceeds the maximum limit"); | ||
| .hasMessageContaining("exceeds the database-level maximum limit"); | ||
| } | ||
|
|
||
| /** Database-level bucket limit should be enforced for non-partitioned tables. */ | ||
| @Test | ||
| void testDatabaseBucketLimitForNonPartitionedTable() throws Exception { | ||
| String dbName = "db_bucket_limit_np"; | ||
| admin.createDatabase(dbName, DatabaseDescriptor.EMPTY, true).get(); | ||
|
|
||
| admin.alterClusterConfigs( | ||
| Collections.singletonList( | ||
| new AlterConfig( | ||
| "database.limits." + dbName + ".max.bucket.num", | ||
| "12", | ||
| AlterConfigOpType.SET))) | ||
| .get(); | ||
|
|
||
| TablePath tablePath = TablePath.of(dbName, "t_np_bucket_limit"); | ||
| TableDescriptor tooManyBuckets = | ||
| TableDescriptor.builder() | ||
| .schema( | ||
| Schema.newBuilder() | ||
| .column("id", DataTypes.STRING()) | ||
| .column("name", DataTypes.STRING()) | ||
| .build()) | ||
| .distributedBy(20, "id") | ||
| .build(); | ||
|
|
||
| assertThatThrownBy(() -> admin.createTable(tablePath, tooManyBuckets, false).get()) | ||
| .cause() | ||
| .isInstanceOf(TooManyBucketsException.class); | ||
|
|
||
| TableDescriptor ok = | ||
| TableDescriptor.builder() | ||
| .schema( | ||
| Schema.newBuilder() | ||
| .column("id", DataTypes.STRING()) | ||
| .column("name", DataTypes.STRING()) | ||
| .build()) | ||
| .distributedBy(12, "id") | ||
| .build(); | ||
| admin.createTable(tablePath, ok, true).get(); | ||
| } | ||
|
|
||
| /** Database-level bucket limit should cap total buckets for partitioned tables. */ | ||
| @Test | ||
| void testDatabaseBucketLimitForPartitionedTable() throws Exception { | ||
| String dbName = "db_bucket_limit_part"; | ||
| admin.createDatabase(dbName, DatabaseDescriptor.EMPTY, true).get(); | ||
|
|
||
| admin.alterClusterConfigs( | ||
| Collections.singletonList( | ||
| new AlterConfig( | ||
| "database.limits." + dbName + ".max.bucket.num", | ||
| "25", | ||
| AlterConfigOpType.SET))) | ||
| .get(); | ||
|
|
||
| TablePath tablePath = TablePath.of(dbName, "t_part_bucket_limit"); | ||
| TableDescriptor td = | ||
| TableDescriptor.builder() | ||
| .schema( | ||
| Schema.newBuilder() | ||
| .column("id", DataTypes.STRING()) | ||
| .column("age", DataTypes.STRING()) | ||
| .build()) | ||
| .distributedBy(10, "id") | ||
| .partitionedBy("age") | ||
| .build(); | ||
| admin.createTable(tablePath, td, true).get(); | ||
|
|
||
| admin.createPartition(tablePath, newPartitionSpec("age", "1"), false).get(); | ||
| admin.createPartition(tablePath, newPartitionSpec("age", "2"), false).get(); | ||
|
|
||
| assertThatThrownBy( | ||
| () -> | ||
| admin.createPartition( | ||
| tablePath, newPartitionSpec("age", "3"), false) | ||
| .get()) | ||
| .cause() | ||
| .isInstanceOf(TooManyBucketsException.class); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
| } | ||
|
|
||
| /** Database-level bucket limit should cap total buckets for partitioned tables. */ | ||
| @Test | ||
| void testDatabaseBucketLimitForAutoPartitionedTable() throws Exception { | ||
| String dbName = "db_bucket_limit_auto_part"; | ||
| admin.createDatabase(dbName, DatabaseDescriptor.EMPTY, true).get(); | ||
|
|
||
| admin.alterClusterConfigs( | ||
| Collections.singletonList( | ||
| new AlterConfig( | ||
| "database.limits." + dbName + ".max.bucket.num", | ||
| "25", | ||
| AlterConfigOpType.SET))) | ||
| .get(); | ||
|
|
||
| TablePath tablePath = TablePath.of(dbName, "t_auto_part_bucket_limit"); | ||
| TableDescriptor td = | ||
| TableDescriptor.builder() | ||
| .schema( | ||
| Schema.newBuilder() | ||
| .column("id", DataTypes.STRING()) | ||
| .column("pt", DataTypes.STRING()) | ||
| .build()) | ||
| .distributedBy(10, "id") | ||
| .partitionedBy("pt") | ||
| .property(ConfigOptions.TABLE_AUTO_PARTITION_ENABLED, true) | ||
| .property( | ||
| ConfigOptions.TABLE_AUTO_PARTITION_TIME_UNIT, | ||
| AutoPartitionTimeUnit.YEAR) | ||
| .build(); | ||
|
|
||
| // default m is 7 | ||
| assertThatThrownBy(() -> admin.createTable(tablePath, td, true).get()) | ||
| .cause() | ||
| .isInstanceOf(TooManyBucketsException.class) | ||
| .hasMessageContaining( | ||
| "The number of buckets to retain must be less than the total number of buckets."); | ||
| } | ||
|
|
||
| /** Database-level bucket limit should only affect the target database. */ | ||
| @Test | ||
| void testDatabaseBucketLimitIsolationAcrossDatabases() throws Exception { | ||
| String db1 = "db_bucket_limit_d1"; | ||
| String db2 = "db_bucket_limit_d2"; | ||
| admin.createDatabase(db1, DatabaseDescriptor.EMPTY, true).get(); | ||
| admin.createDatabase(db2, DatabaseDescriptor.EMPTY, true).get(); | ||
|
|
||
| admin.alterClusterConfigs( | ||
| Collections.singletonList( | ||
| new AlterConfig( | ||
| "database.limits." + db1 + ".max.bucket.num", | ||
| "12", | ||
| AlterConfigOpType.SET))) | ||
| .get(); | ||
|
|
||
| TablePath t1 = TablePath.of(db1, "t_np_bucket_limit_d1"); | ||
| TableDescriptor tooManyForDb1 = | ||
| TableDescriptor.builder() | ||
| .schema( | ||
| Schema.newBuilder() | ||
| .column("id", DataTypes.STRING()) | ||
| .column("name", DataTypes.STRING()) | ||
| .build()) | ||
| .distributedBy(20, "id") | ||
| .build(); | ||
| assertThatThrownBy(() -> admin.createTable(t1, tooManyForDb1, false).get()) | ||
| .cause() | ||
| .isInstanceOf(TooManyBucketsException.class); | ||
|
|
||
| TablePath t2 = TablePath.of(db2, "t_np_bucket_limit_d2"); | ||
| TableDescriptor okForDb2 = | ||
| TableDescriptor.builder() | ||
| .schema( | ||
| Schema.newBuilder() | ||
| .column("id", DataTypes.STRING()) | ||
| .column("name", DataTypes.STRING()) | ||
| .build()) | ||
| .distributedBy(20, "id") | ||
| .build(); | ||
| // cluster max.bucket.num is 30 in base config, so 20 should succeed in db2 | ||
| admin.createTable(t2, okForDb2, true).get(); | ||
| } | ||
|
|
||
| /** Test that creating a table with system columns throws InvalidTableException. */ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert the message as well, the message should be clear to user the given database has exceed the allowed number of buckets.