Repository navigation
Expose backup/restore settings in system.backups and system.backup_log - #108334
Conversation
Add two Map(String, String) columns to system.backups and system.backup_log: - `settings`: the backup/restore-specific settings requested for the operation (the fields of `BackupSettings`/`RestoreSettings`, e.g. `allow_s3_native_copy`, `deduplicate_files`). These are not query settings, so they don't appear in the structured `system.query_log.Settings` map (only in the raw `query` text); this column gives structured access to their effective values, including defaults the user didn't type. The general query settings passed in the same SETTINGS clause (e.g. `backup_slow_all_threads_after_retryable_s3_error`) are applied to the query context and remain observable via `system.query_log.Settings` joined on `query_id`, so they are not duplicated here. Sensitive settings are not exposed. - `engine_settings`: the settings effectively used by the backup engine's reader/writer (e.g. the S3 request settings such as `allow_native_copy`), which may differ from the requested settings because they also include global and endpoint configuration. Previously settings like `allow_s3_native_copy` were consumed during the operation and not observable anywhere. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Workflow [PR], commit [fd69cfb] Summary: ✅
AI ReviewSummaryThis PR exposes backup/restore-specific Final VerdictStatus: ✅ Approve |
…ttings-observability
Mark the `getSettingsRepresentation` std::map usages with STYLE_CHECK_ALLOW_STD_CONTAINERS (src/IO is linted for raw std containers). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
addcf33 to
aad639a
Compare
makeS3Client overrides several request-settings values (retries, redirects, timeout, slow-thread/logging behavior). Replace those entries in engine_settings with the authoritative values from the client configuration. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
aad639a to
a41f7e2
Compare
Azure backup reads use read_settings.remote_fs_settings.min_bytes_for_seek, not RequestSettings::min_bytes_for_seek. Report the former. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
S3 backup reads use read_settings.remote_fs_settings.min_bytes_for_seek, not RequestSettings::min_bytes_for_seek. Report the former (as Azure does). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Restore with non-default restore-specific settings and assert both system.backups and the final system.backup_log row expose them while hiding password/id. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The SELECT * examples would silently omit the new settings/engine_settings columns. List the displayed columns explicitly so the example output stays accurate. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Use SYSTEM FLUSH LOGS backup_log instead of the global form. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
04409: also assert structure_only in settings (a named restore setting). 04410: assert engine_settings is populated for an S3 RESTORE and reflects allow_s3_native_copy. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Extend 04339 to flush and read the persisted system.backup_log row, checking a settings value and the non-empty engine_settings shape. This exercises the log-specific BackupLogElement::appendToBlock path. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
S3RequestSettings::finishInit derives the client throttlers from s3_max_*_rps and substitutes default bursts, so the raw request-settings values mislead. Report max_get_rps/max_get_burst/max_put_rps/max_put_burst from client_config.request_throttler (0 when no throttler). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ttings-observability
There was a problem hiding this comment.
Pull request overview
Adds structured observability for BACKUP/RESTORE by exposing two new Map(LowCardinality(String), String) columns (settings, engine_settings) in system.backups and system.backup_log, and plumbing those values from backup/restore settings plus engine-specific reader/writer configuration (S3/Azure).
Changes:
- Add
settingsandengine_settingscolumns tosystem.backupsandsystem.backup_log, and populate them fromBackupSettings/RestoreSettingsplus backup engine readers/writers. - Implement engine settings serialization for S3/Azure backup IO and expose it via
IBackup::getEngineSettings. - Add stateless query tests and update documentation for the new system table columns.
Reviewed changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/queries/0_stateless/04410_system_backups_restore_engine_settings.sh | New S3 restore test asserting engine_settings is populated and reflects allow_s3_native_copy. |
| tests/queries/0_stateless/04410_system_backups_restore_engine_settings.reference | Expected output for 04410 test. |
| tests/queries/0_stateless/04409_system_backups_restore_settings.sh | New test asserting restore-specific settings appear in system.backups/system.backup_log and secrets/internal fields don’t. |
| tests/queries/0_stateless/04409_system_backups_restore_settings.reference | Expected output for 04409 test. |
| tests/queries/0_stateless/04339_system_backups_engine_settings.sh | New S3 backup test asserting engine_settings population and persisted exposure in system.backup_log. |
| tests/queries/0_stateless/04339_system_backups_engine_settings.reference | Expected output for 04339 test. |
| tests/queries/0_stateless/04338_system_backups_settings.sh | New test asserting backup-specific settings exposure and empty engine_settings for Disk engine. |
| tests/queries/0_stateless/04338_system_backups_settings.reference | Expected output for 04338 test. |
| src/Storages/System/StorageSystemBackups.cpp | Adds settings/engine_settings columns to system.backups and fills them from worker info. |
| src/IO/S3RequestSettings.h | Declares S3RequestSettings::getSettingsRepresentation for observability. |
| src/IO/S3RequestSettings.cpp | Implements getSettingsRepresentation by dumping effective request settings to a string map. |
| src/Interpreters/BackupLog.cpp | Adds settings/engine_settings columns to system.backup_log and appends maps into log blocks. |
| src/Backups/RestoreSettings.h | Declares RestoreSettings::getSerializedSettings. |
| src/Backups/RestoreSettings.cpp | Implements restore-settings serialization with filtering of secret/internal keys. |
| src/Backups/IBackup.h | Extends IBackup with getEngineSettings to expose engine reader/writer effective settings. |
| src/Backups/BackupsWorker.h | Threads settings through addInfo and adds setEngineSettings. |
| src/Backups/BackupsWorker.cpp | Records requested settings at start and engine effective settings after opening backup for read/write. |
| src/Backups/BackupSettings.h | Declares BackupSettings::getSerializedSettings. |
| src/Backups/BackupSettings.cpp | Implements backup-settings serialization with filtering of secret/internal keys. |
| src/Backups/BackupOperationInfo.h | Stores per-operation settings and engine_settings maps in in-memory operation info. |
| src/Backups/BackupIO.h | Adds default getSerializedSettings hooks to IBackupReader/IBackupWriter. |
| src/Backups/BackupIO_S3.h | Declares S3 reader/writer getSerializedSettings overrides. |
| src/Backups/BackupIO_S3.cpp | Implements S3 reader/writer settings serialization (request settings + client-config overrides + throttler/seek info). |
| src/Backups/BackupIO_AzureBlobStorage.h | Declares Azure reader/writer getSerializedSettings overrides. |
| src/Backups/BackupIO_AzureBlobStorage.cpp | Implements Azure request settings serialization for observability. |
| src/Backups/BackupImpl.h | Declares BackupImpl::getEngineSettings. |
| src/Backups/BackupImpl.cpp | Implements getEngineSettings by delegating to reader/writer serialized settings. |
| docs/en/operations/system-tables/backups.md | Documents the new settings and engine_settings columns in system.backups. |
| docs/en/operations/system-tables/backup_log.md | Documents the new columns in system.backup_log and adjusts example queries to avoid SELECT *. |
| std::map<String, String> res; | ||
|
|
||
| #define SERIALIZE_BACKUP_SETTING(TYPE, NAME) \ | ||
| res[#NAME] = convertFieldToString(static_cast<Field>(SettingField##TYPE{NAME})); |
There was a problem hiding this comment.
GPT-5.5 reported this, which makes sense:
settings serializes every setting through convertFieldToString(static_cast(...)). For String-backed settings this stores SQL-literal text with embedded quotes, because FieldVisitorToString formats strings as quoted literals. For example compression_method='zstd' would be exposed as 'zstd' rather than zstd, and restore enum/string values like if-not-exists get the same treatment. That is inconsistent with system.query_log.Settings and the new engine_settings path, and makes straightforward predicates like settings['compression_method'] = 'zstd' fail.
Suggested fix: serialize via the setting field’s raw toString representation instead of converting through FieldVisitorToString; add toString helpers for backup-specific wrapper fields where needed.
Adding a new test to assert the stored map value doesn't contain without embedded quote characters would be 🚀
The same for RestoreSettings.cpp
There was a problem hiding this comment.
This is addressed (commit a351381): both BackupSettings::getSerializedSettings and RestoreSettings::getSerializedSettings now serialize via the setting field's own toString instead of FieldVisitorToString/convertFieldToString, so String-backed settings are stored verbatim without SQL-literal quotes. 04338_system_backups_settings requests compression_method='zstd' and asserts settings['compression_method'] = 'zstd' holds (no embedded quotes), per your 🚀 suggestion. Neither file references convertFieldToString anymore.
There was a problem hiding this comment.
AI made the comment above.
…tings Mirror the S3 fix: omit read_only and list_object_keys_size (and the http_keep_alive_* fields, which come from server settings) from the Azure engine_settings map, since backup Azure IO never consumes them and reporting them is misleading. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
An incremental or lightweight-snapshot restore reads from additional readers (the base backup, the lightweight snapshot reader) whose endpoint request settings can differ from the top-level backup, so the single flat engine_settings map would be misleading. Report it only when the top-level backup is the sole reader. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
…ngine `BackupImpl::getEngineSettings` returned the writer's serialized settings unconditionally for any backup. For an incremental BACKUP this is misleading: such a backup writes through the destination engine but also reads from the base backup, i.e. two engines with potentially different endpoint settings, which a flat `Map` cannot represent. The reader/RESTORE path already omits `engine_settings` when more than one reader is involved (the base backup for incremental restores and the lightweight snapshot reader); apply the same guard uniformly so the writer/BACKUP path omits the map whenever a base backup is present. Adds `04411_system_backups_incremental_engine_settings` asserting that a plain S3 backup populates `engine_settings` while an incremental S3 backup reports an empty map in both `system.backups` and `system.backup_log`. Addresses review feedback on #108334 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
For a non-internal `BACKUP`/`RESTORE ON CLUSTER` the initiator only opens the backup locally; the data is written/read by per-host internal operations (filtered out of `system.backups`) that may use different engine settings. So the initiator's reader/writer does not represent the whole operation. Omit `engine_settings` in that case, as is already done for incremental multi-engine operations, and document in the column descriptions that the map is empty whenever more than one engine can be involved. Addresses review feedback on #108334 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
pamarcos
left a comment
There was a problem hiding this comment.
I requested another review from Copilot and added some nitpicks. Most of them are non-important, so I'm approving it already. There are a few regarding docs that are worth addressing.
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 170/181 (93.92%) | Lost baseline coverage (was covered on master, now uncovered in this PR): 2 line(s) · Uncovered code |
…ngine `BackupImpl::getEngineSettings` returned the writer's serialized settings unconditionally for any backup. For an incremental BACKUP this is misleading: such a backup writes through the destination engine but also reads from the base backup, i.e. two engines with potentially different endpoint settings, which a flat `Map` cannot represent. The reader/RESTORE path already omits `engine_settings` when more than one reader is involved (the base backup for incremental restores and the lightweight snapshot reader); apply the same guard uniformly so the writer/BACKUP path omits the map whenever a base backup is present. Adds `04411_system_backups_incremental_engine_settings` asserting that a plain S3 backup populates `engine_settings` while an incremental S3 backup reports an empty map in both `system.backups` and `system.backup_log`. Addresses review feedback on ClickHouse#108334 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
For a non-internal `BACKUP`/`RESTORE ON CLUSTER` the initiator only opens the backup locally; the data is written/read by per-host internal operations (filtered out of `system.backups`) that may use different engine settings. So the initiator's reader/writer does not represent the whole operation. Omit `engine_settings` in that case, as is already done for incremental multi-engine operations, and document in the column descriptions that the map is empty whenever more than one engine can be involved. Addresses review feedback on ClickHouse#108334 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…-settings-observability Expose backup/restore settings in system.backups and system.backup_log
Adds two
Map(String, String)columns tosystem.backupsandsystem.backup_logso that the settings of aBACKUP/RESTOREoperation are observable:settings— the backup/restore-specific settings requested for the operation (the fields ofBackupSettings/RestoreSettings, e.g.allow_s3_native_copy,deduplicate_files,structure_only). These are not query settings, so they don't appear in the structuredsystem.query_log.Settingsmap (only in the rawquerytext); this column gives structured, queryable access to their effective values, including defaults the user didn't type. The general query settings passed in the sameSETTINGSclause (e.g.backup_slow_all_threads_after_retryable_s3_error) are applied to the query context and remain observable viasystem.query_log.Settingsjoined onquery_id, so they are not duplicated here. Sensitive settings are not exposed.engine_settings— the settings effectively used by the backup engine's reader/writer (e.g. the S3 request settings such asallow_native_copy,storage_class_name, retry settings). These are the authoritative values after merging global, endpoint and query configuration, so they may differ from the requestedsettings.Motivation: settings such as
allow_s3_native_copywere consumed during the operation and discarded, so there was no direct way to see what a given backup actually ran with. Reconstructing it meant piecing together indirect signals:SETTINGSclause from thequerytext insystem.query_log— but only what the user explicitly typed;Client::logConfigurationemits);ProfileEvents(e.g.ProfileEvents['S3CopyObject'] > 0to tell whether native copy actually happened).These new columns make all of that directly queryable in one place. The effective engine settings (
engine_settings) are plumbed from the backup reader/writer viaIBackupReader/IBackupWriter::getSerializedSettings(overridden by the S3 and Azure engines; empty by default for File/Disk/Memory/Null).Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Added
settingsandengine_settingscolumns tosystem.backupsandsystem.backup_log.settingsexposes the backup/restore-specific settings requested for an operation (e.g.allow_s3_native_copy,deduplicate_files,structure_only), andengine_settingsexposes the settings effectively used by the backup engine's reader/writer (e.g. the S3 request settings such asallow_native_copy, which may differ from what was requested after merging endpoint configuration). This makes it possible to see which settings aBACKUP/RESTOREoperation actually ran with.Documentation entry for user-facing changes
docs/en/operations/system-tables/backups.mdandbackup_log.md).Version info
26.7.1.280(included in26.7and later)