Skip to content

Add setting max_backup_bandwidth to backup/restore query - #72665

Merged
vitlibar merged 1 commit into
ClickHouse:masterfrom
cwurm:max_backup_bandwidth
Dec 17, 2024
Merged

vitlibar merged 1 commit into
ClickHouse:masterfrom
cwurm:max_backup_bandwidth

Conversation

@cwurm

@cwurm cwurm commented Dec 2, 2024

Copy link
Copy Markdown
Member

At the moment, max_backup_bandwidth cannot be set directly in the BACKUP/RESTORE query, it has to be set for the session, e.g., via SET max_backup_bandwidth=N, clickhouse-client --max_backup_bandwidth=N or URL parameter.

This PR allows specifying it with BACKUP|RESTORE ... SETTINGS max_backup_bandwidth= making it more straightforward to use.

There is a bit of a quirk where max_backup_bandwidth also applies to RESTORE. It might be more logical to have a setting max_restore_bandwidth. But since the setting applies to both BACKUP and RESTORE commands today when set for the session I've also added it as a query setting for both.

I thought of adding a brand new test but it felt like overkill given it would just be copying an existing test and specifying the setting differently. So I modified an existing test, hope that's ok.

Changelog category (leave one):

  • Improvement

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

Adds setting max_backup_bandwidth to the list of settings that can be specified as part of BACKUP/RESTORE queries.

@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-improvement Pull request with some product improvements label Dec 2, 2024
@robot-clickhouse-ci-1

robot-clickhouse-ci-1 commented Dec 2, 2024 •

Copy link
Copy Markdown
Contributor

This is an automated comment for commit a8a4e0e 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
BuildsThere's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
ClickBenchRuns [ClickBench](https://github.com/ClickHouse/ClickBench/) with instant-attach table✅ success
Compatibility checkChecks that clickhouse binary runs on distributions with old libc versions. If it fails, ask a maintainer for help✅ success
Docker keeper imageThe check to build and optionally push the mentioned image to docker hub✅ success
Docker server imageThe check to build and optionally push the mentioned image to docker hub✅ success
Docs checkBuilds and tests the documentation✅ 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. Integration 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
Performance ComparisonMeasure changes in query performance. The performance test report is described in detail here. In square brackets are the optional part/total tests✅ success
Stateful testsRuns stateful functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc✅ success
Stateless testsRuns stateless 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
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✅ success


query_id=$(random_str 10)
$CLICKHOUSE_CLIENT --query_id "$query_id" -q "backup table data to Disk('backups', '$CLICKHOUSE_DATABASE/data/backup1')" --max_backup_bandwidth=1M > /dev/null
$CLICKHOUSE_CLIENT --query_id "$query_id" -q "backup table data to Disk('backups', '$CLICKHOUSE_DATABASE/data/backup1') SETTINGS max_backup_bandwidth=1e6" > /dev/null

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Worth to add a separate test case (just a below in this file) for newly added setting instead of replacing existing.

@vitlibar vitlibar self-assigned this Dec 2, 2024
std::optional<UUID> backup_uuid;

/// The maximum read speed in bytes per second for a backup. Zero means unlimited.
std::optional<UInt64> max_backup_bandwidth;

@vitlibar vitlibar Dec 2, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's not the first time when we need to pass a global setting to BACKUP or RESTORE command, so I believe it will be useful to support not only max_backup_bandwidth but any global settings after BACKUP ... SETTINGS and after RESTORE ... SETTINGS.

In order to do that just replace this field here in BackupSettings with

SettingsChanges other_settings;

and also replace throwing an exception in BackupSettings::fromBackupQuery() with

other_settings.emplace_back(setting);

and add call backup_context->applySettingsChanges(backup_settings.other_settings) after making backup_context in BackupStarter::BackupStarter.

@vitlibar

vitlibar commented Dec 17, 2024 •

Copy link
Copy Markdown
Member

I think I'll merge this PR and then I'll do some refactoring to allow other global settings after BACKUP ... SETTINGS as well.

@vitlibar
vitlibar enabled auto-merge December 17, 2024 15:58
@cwurm

cwurm commented Dec 17, 2024

Copy link
Copy Markdown
Member Author

I think I'll merge this PR and then I'll do some refactoring to allow other global settings after BACKUP ... SETTINGS as well.

Ok, sure. It was on my list of things to do, but hard to find the time. Happy for you to do it, thanks!

@vitlibar
vitlibar added this pull request to the merge queue Dec 17, 2024
Merged via the queue into ClickHouse:master with commit 11c86ed Dec 17, 2024
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Dec 17, 2024
@cwurm
cwurm deleted the max_backup_bandwidth branch December 17, 2024 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants