Skip to content

Expose backup/restore settings in system.backups and system.backup_log - #108334

Merged
jkartseva merged 23 commits into
masterfrom
jkartseva/backup-settings-observability
Jun 30, 2026
Merged

jkartseva merged 23 commits into
masterfrom
jkartseva/backup-settings-observability

Conversation

@jkartseva

@jkartseva jkartseva commented Jun 23, 2026 •

Copy link
Copy Markdown
Member

Adds two Map(String, String) columns to system.backups and system.backup_log so that the settings of a BACKUP/RESTORE operation are observable:

  • settings — the backup/restore-specific settings requested for the operation (the fields of BackupSettings/RestoreSettings, e.g. allow_s3_native_copy, deduplicate_files, structure_only). 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, queryable 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, storage_class_name, retry settings). These are the authoritative values after merging global, endpoint and query configuration, so they may differ from the requested settings.

Motivation: settings such as allow_s3_native_copy were 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:

  • reading the literal SETTINGS clause from the query text in system.query_log — but only what the user explicitly typed;
  • assuming the source-code/version defaults for everything left unset;
  • scanning server trace logs (e.g. the handful of values Client::logConfiguration emits);
  • inferring effective behavior from ProfileEvents (e.g. ProfileEvents['S3CopyObject'] > 0 to 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 via IBackupReader/IBackupWriter::getSerializedSettings (overridden by the S3 and Azure engines; empty by default for File/Disk/Memory/Null).

Changelog category (leave one):

  • Improvement

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

Added settings and engine_settings columns to system.backups and system.backup_log. settings exposes the backup/restore-specific settings requested for an operation (e.g. allow_s3_native_copy, deduplicate_files, structure_only), and engine_settings exposes 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 what was requested after merging endpoint configuration). This makes it possible to see which settings a BACKUP/RESTORE operation actually ran with.

Documentation entry for user-facing changes

  • Documentation is written (new columns documented in docs/en/operations/system-tables/backups.md and backup_log.md).

Version info

  • Merged into: 26.7.1.280 (included in 26.7 and later)

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]>
@clickhouse-gh

clickhouse-gh Bot commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [fd69cfb]

Summary: ✅


AI Review

Summary

This PR exposes backup/restore-specific settings and backup-engine engine_settings in system.backups and system.backup_log. I reviewed the current code, prior review threads, docs, tests, and the Praktika report; the earlier issues around stale examples, quoted string serialization, misleading S3/Azure fields, multi-engine operations, and missing log coverage are addressed in the current head. I did not find any new correctness, safety, compatibility, or documentation issues that warrant inline comments.

Final Verdict

Status: ✅ Approve

@jkartseva jkartseva added the can be tested Allows running workflows for external contributors label Jun 23, 2026
@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Jun 23, 2026
Comment thread src/Backups/BackupIO_S3.h Resolved
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]>
@jkartseva
jkartseva force-pushed the jkartseva/backup-settings-observability branch from addcf33 to aad639a Compare June 24, 2026 00:01
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]>
@jkartseva
jkartseva force-pushed the jkartseva/backup-settings-observability branch from aad639a to a41f7e2 Compare June 24, 2026 00:03
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]>
Comment thread src/Backups/BackupIO_S3.cpp Resolved
jkartseva and others added 5 commits June 24, 2026 00:37
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]>
Comment thread src/Backups/BackupIO_S3.cpp Resolved
jkartseva and others added 3 commits June 24, 2026 01:51
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]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 settings and engine_settings columns to system.backups and system.backup_log, and populate them from BackupSettings/RestoreSettings plus 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 *.

Comment thread src/Backups/BackupSettings.cpp Outdated
std::map<String, String> res;

#define SERIALIZE_BACKUP_SETTING(TYPE, NAME) \
res[#NAME] = convertFieldToString(static_cast<Field>(SettingField##TYPE{NAME}));

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.

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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]>
Comment thread src/Backups/BackupsWorker.cpp Resolved
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]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 33 out of 33 changed files in this pull request and generated 1 comment.

Comment thread src/Backups/BackupImpl.cpp Resolved
Comment thread src/Backups/BackupImpl.cpp Resolved
jkartseva and others added 2 commits June 26, 2026 16:25
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]>
Comment thread src/Backups/BackupsWorker.cpp Resolved
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]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 35 out of 35 changed files in this pull request and generated 8 comments.

Comment thread src/Interpreters/BackupLog.cpp Resolved
Comment thread src/Backups/BackupOperationInfo.h Resolved

@pamarcos pamarcos left a comment

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.

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.

jkartseva and others added 2 commits June 29, 2026 13:27
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.40% 85.40% +0.00%
Functions 92.60% 92.60% +0.00%
Branches 77.60% 77.70% +0.10%

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

Full report · Diff report

@jkartseva
jkartseva enabled auto-merge June 30, 2026 00:28
@jkartseva
jkartseva added this pull request to the merge queue Jun 30, 2026
Merged via the queue into master with commit ca01d73 Jun 30, 2026
174 checks passed
@jkartseva
jkartseva deleted the jkartseva/backup-settings-observability branch June 30, 2026 03:35
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 30, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…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]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
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]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…-settings-observability

Expose backup/restore settings in system.backups and system.backup_log
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 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.

4 participants