Skip to content
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

Add changeable_without_restart column to system.server_settings #58029

Merged
merged 10 commits into from Jan 8, 2024

Conversation

skyoct
Copy link
Contributor

@skyoct skyoct commented Dec 19, 2023

Fixes #57902

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

Replaced undocumented (boolean) column is_hot_reloadable in system table system.server_settings by (Enum8) column changeable_without_restart with possible values No, Yes, IncreaseOnly and DecreaseOnly. Also documented the column.

@rschu1ze rschu1ze self-assigned this Dec 19, 2023
Comment on lines 26 to 27
#define M_WITH_FLAG_(M, TYPE, NAME, DEFAULT, DESCRIPTION, FLAGS, RUNTIME_RELOAD) \
M(TYPE, NAME, DEFAULT, DESCRIPTION, FLAGS) \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like too many letters, Can we leave just M and change a few other macros?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@serxa Hi, I'm sorry, I don't quite understand what you mean. Perhaps you are referring to the macro's name being too long?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking it should be possible to use M(TYPE, NAME, DEFAULT, DESCRIPTION, FLAGS, RUNTIME_RELOAD) directly, but now I see that SERVER_SETTINGS is passed directly to DECLARE_SETTINGS_TRAITS which is used in a lot of places, so changing it is not a good idea.

But, yes macro's name still feels too long to me, just because almost everywhere we use M(X, Y, Z) do declare such a list. Let's ask @rschu1ze for his opinion. I was just glad to see this PR :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@serxa Ok, The new macro name does sound awkward, and I will make sure to modify it later.

@skyoct skyoct marked this pull request as ready for review December 20, 2023 13:32
@rschu1ze rschu1ze added the can be tested Allows running workflows for external contributors label Dec 21, 2023
@rschu1ze rschu1ze changed the title Add runtime_reload column to system.server_settings table Add runtime_reload column to system.server_settings Dec 21, 2023
@robot-clickhouse robot-clickhouse added the pr-improvement Pull request with some product improvements label Dec 21, 2023
@robot-clickhouse
Copy link
Member

robot-clickhouse commented Dec 21, 2023

This is an automated comment for commit 8cd8552 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
Check nameDescriptionStatus
AST fuzzerRuns randomly generated queries to catch program errors. The build type is optionally given in parenthesis. If it fails, ask a maintainer for help✅ success
ClickBenchRuns [ClickBench](https://github.com/ClickHouse/ClickBench/) with instant-attach table✅ success
ClickHouse build checkBuilds ClickHouse in various configurations for use in further steps. You have to fix the builds that fail. Build logs often has enough information to fix the error, but you might have to reproduce the failure locally. The cmake options can be found in the build log, grepping for cmake. Use these options and follow the general build process✅ success
Compatibility checkChecks that clickhouse binary runs on distributions with old libc versions. If it fails, ask a maintainer for help✅ success
Docker image for serversThe check to build and optionally push the mentioned image to docker hub✅ success
Docs checkThere's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
Fast testNormally this is the first check that is ran for a PR. It builds ClickHouse and runs most of stateless functional tests, omitting some. If it fails, further checks are not started until it is fixed. Look at the report to see which tests fail, then reproduce the failure locally as described here✅ success
Flaky testsChecks if new added or modified tests are flaky by running them repeatedly, in parallel, with more randomization. Functional tests are run 100 times with address sanitizer, and additional randomization of thread scheduling. Integrational tests are run up to 10 times. If at least once a new test has failed, or was too long, this check will be red. We don't allow flaky tests, read the doc✅ success
Install packagesChecks that the built packages are installable in a clear environment✅ success
Integration testsThe integration tests report. In parenthesis the package type is given, and in square brackets are the optional part/total tests✅ success
Mergeable CheckChecks if all other necessary checks are successful✅ success
SQLTestThere's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
SQLancerFuzzing tests that detect logical bugs with SQLancer tool✅ success
SqllogicRun clickhouse on the sqllogic test set against sqlite and checks that all statements are passed✅ success
Stateful testsRuns stateful functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc✅ success
Stress testRuns stateless functional tests concurrently from several clients to detect concurrency-related errors✅ success
Style CheckRuns a set of checks to keep the code style clean. If some of tests failed, see the related log from the report✅ success
Unit testsRuns the unit tests for different release types✅ success
Check nameDescriptionStatus
CI runningA meta-check that indicates the running CI. Normally, it's in success or pending state. The failed status indicates some problems with the PR⏳ pending
Performance ComparisonMeasure changes in query performance. The performance test report is described in detail here. In square brackets are the optional part/total tests❌ failure
Stateless testsRuns stateless functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc❌ failure
Upgrade checkRuns stress tests on server version from last release and then tries to upgrade it to the version from the PR. It checks if the new server can successfully startup without any errors, crashes or sanitizer asserts❌ failure

@@ -28,7 +47,8 @@ NamesAndTypesList StorageSystemServerSettings::getNamesAndTypes()
{"description", std::make_shared<DataTypeString>()},
{"type", std::make_shared<DataTypeString>()},
{"is_obsolete", std::make_shared<DataTypeUInt8>()},
{"is_hot_reloadable", std::make_shared<DataTypeUInt8>()}
{"is_hot_reloadable", std::make_shared<DataTypeUInt8>()},
{"runtime_reload", std::make_shared<DataTypeEnum8>(getTypeEnumsAndValues())}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no restriction that new columns must be appended, we can insert them at arbitrary positions and even permute the order of existing columns.

Thoughts:

  • is_obsolete should be the last column
  • is_hot_reloadable and runtime_reload are related columns and should therefore be adjacent to each other
  • let's move the two former columns prior to is_obsolete.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runtime_reload isn't a great name (is_hot_reloadable isn't either but it is too late to change it, I guess).

So if I understand correctly, 'is_hot_reloadableshows *if* a server setting can be changed andruntime_reload` shows how it can be changed. There is some duplication here. I think the latter is conceptually a full replacement of the former, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rschu1ze I think perhaps the value of "is_hot_reloadable" is problematic. It seems that only those that undergo changes (where the set value is inconsistent with the displayed value) will be shown as true.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::unordered_map<std::string, std::string> updated = {
{"max_server_memory_usage", std::to_string(total_memory_tracker.getHardLimit())},
{"allow_use_jemalloc_memory", std::to_string(total_memory_tracker.getAllowUseJemallocMmemory())},
{"max_table_size_to_drop", std::to_string(context->getMaxTableSizeToDrop())},
{"max_partition_size_to_drop", std::to_string(context->getMaxPartitionSizeToDrop())},
{"max_concurrent_queries", std::to_string(context->getProcessList().getMaxSize())},
{"max_concurrent_insert_queries", std::to_string(context->getProcessList().getMaxInsertQueriesAmount())},
{"max_concurrent_select_queries", std::to_string(context->getProcessList().getMaxSelectQueriesAmount())},
{"background_buffer_flush_schedule_pool_size", std::to_string(CurrentMetrics::get(CurrentMetrics::BackgroundBufferFlushSchedulePoolSize))},
{"background_schedule_pool_size", std::to_string(CurrentMetrics::get(CurrentMetrics::BackgroundSchedulePoolSize))},
{"background_message_broker_schedule_pool_size", std::to_string(CurrentMetrics::get(CurrentMetrics::BackgroundMessageBrokerSchedulePoolSize))},
{"background_distributed_schedule_pool_size", std::to_string(CurrentMetrics::get(CurrentMetrics::BackgroundDistributedSchedulePoolSize))}
};
if (context->areBackgroundExecutorsInitialized())
{
updated.insert({"background_pool_size", std::to_string(context->getMergeMutateExecutor()->getMaxThreads())});
updated.insert({"background_move_pool_size", std::to_string(context->getMovesExecutor()->getMaxThreads())});
updated.insert({"background_fetches_pool_size", std::to_string(context->getFetchesExecutor()->getMaxThreads())});
updated.insert({"background_common_pool_size", std::to_string(context->getCommonExecutor()->getMaxThreads())});
}

res_columns[7]->insert((it != updated.end()) ? true : false);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rschu1ze Hi, Can I delete "is_hot_reloadable" and change "runtime_reload" to "hot_reload"?

src/Storages/System/StorageSystemServerSettings.cpp Outdated Show resolved Hide resolved
src/Storages/System/StorageSystemServerSettings.cpp Outdated Show resolved Hide resolved
src/Storages/System/StorageSystemServerSettings.cpp Outdated Show resolved Hide resolved
src/Storages/System/StorageSystemServerSettings.cpp Outdated Show resolved Hide resolved
@rschu1ze rschu1ze changed the title Add runtime_reload column to system.server_settings Add changeable_without_restart column to system.server_settings Jan 7, 2024
@rschu1ze
Copy link
Member

rschu1ze commented Jan 7, 2024

@skyoct I just came back to your PR (after holidays) and checked deeper. Someone added a boolean column is_hot_reloadable already and it overlaps with what this PR tries to achieve. Luckily, is_hot_reloadable was never documented, so we might get away with hijacking it for our purposes, i.e. change its data type from Bool to Enum8 with values Yes, No, IncreaseOnly and DecreaseOnly. Also, the existing map updated could be extended with an enum to indicate how the value is reloadable. With that, ServerSettings.h/cpp can remain as is. I made these changes and pushed them.

The advantage of the new approach is that ServerSettings.h/cpp and StorageSystemServerSettings.cpp cannot easily go out-of-sync (imagine someone adds ChangeableAtRuntime::Yes in ServerSettings but forgets to modify the updated map in StorageSystemServerSettings.cpp)...

But to be fair, all of that is based on the fact that the periodic re-loads of the server config only update the server components (e.g. memory tracking) with the new setting values but do not store the settings themselves (so we can't get them directly). If that was the case, your approach would be better. I actually like it conceptually better as we could then use the ChangeableWithoutRestart property to accept/reject changes of server settings at runtime (right now, it is only used by the system view). Anyways, that would be a bigger rewrite.

Besides that, I named the new column changeable_without_restart (as mentioned already) and marked various caches as such. I guess there are a lot more server settings which can be changed at runtime but that can be fixed in separate PR(s).

@rschu1ze rschu1ze merged commit 6665d23 into ClickHouse:master Jan 8, 2024
254 of 264 checks passed
@skyoct skyoct deleted the feat/server_settings branch January 8, 2024 09:12
@azat
Copy link
Collaborator

azat commented Feb 19, 2024

The advantage of the new approach is that ServerSettings.h/cpp and StorageSystemServerSettings.cpp cannot easily go out-of-sync (imagine someone adds ChangeableAtRuntime::Yes in ServerSettings but forgets to modify the updated map in StorageSystemServerSettings.cpp)...

This may also force developers to write the reloading handler for a newly added settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
can be tested Allows running workflows for external contributors pr-improvement Pull request with some product improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mark every setting in ServerSettings as hot-reloadable or not.
5 participants