-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Feature database and table count limitation issue56347 #64781
Feature database and table count limitation issue56347 #64781
Conversation
This is an automated comment for commit c32b97d with description of existing statuses. It's updated for the latest CI running ❌ Click here to open a full report in a separate page
Successful checks
|
{ | ||
size_t db_count = DatabaseCatalog::instance().getDatabases().size(); | ||
// there's an invisible system database _temporary_and_external_tables, so we need to subtract 1 | ||
if (db_count > 0) |
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.
I think it makes sense to check that this hidden system DB is actually present && DatabaseCatalog::instance().isDatabaseExist(DatabaseCatalog::TEMPORARY_DATABASE)
# Generate config.xml | ||
CONFIG_FILE="$TEMP_DIR/config.xml" | ||
cat > "$CONFIG_FILE" <<EOL | ||
<yandex> |
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.
- We have left yandex :)
- Don't do this in stateless test :( we write integration tests to test special config
@@ -0,0 +1,21 @@ | |||
create database db1; |
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.
Don't do this .... we only have .sql
and .reference
in 0_stateless
directory
I write an integration test to replace original one. Feel free to amend/revert if you do not agree :) I have another question, why we don't care about system tables for tables limit, but have to care |
@@ -138,6 +145,18 @@ BlockIO InterpreterCreateQuery::createDatabase(ASTCreateQuery & create) | |||
throw Exception(ErrorCodes::DATABASE_ALREADY_EXISTS, "Database {} already exists.", database_name); | |||
} | |||
|
|||
if (auto max_db = getContext()->getGlobalContext()->getServerSettings().max_database_num_to_throw; max_db > 0) |
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.
We can write two lines, don't have to be tooo brief
@@ -1537,6 +1556,16 @@ bool InterpreterCreateQuery::doCreateTable(ASTCreateQuery & create, | |||
} | |||
} | |||
|
|||
if (UInt64 max_table = getContext()->getGlobalContext()->getServerSettings().max_table_num_to_throw; max_table > 0) |
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.
ditto
UInt64 table_count = CurrentMetrics::get(CurrentMetrics::AttachedTable); | ||
if (table_count >= max_table) | ||
throw Exception(ErrorCodes::TOO_MANY_TABLES, | ||
"Too many tables in the system. Current is {}, limit is {}. " |
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.
How about using one sentence:
Too many tables in ClickHouse. The limit (setting 'max_table_num_to_throw') is set to {}
Same for databases.
Besides, do not write period at the end.
max_table_num_to_throw max_database_num_to_throw
…plicitly, change 'yandex' into 'clickhouse' in config.xml
Head branch was pushed to by a user without write access
Pull request was closed
8112250
to
594a0e9
Compare
issue: #56347
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Add server settings
max_table_num_to_throw
andmax_database_num_to_throw
to limit the number of databases or tables onCREATE
queries.Documentation entry for user-facing changes
CI Settings (Only check the boxes if you know what you are doing):