Skip to content

Snapshot backup entries should not use backup io thread - #112297

Merged
hanfei1991 merged 1 commit into
ClickHouse:masterfrom
hanfei1991:hanfei/reduce-snapshot-cpu-spike
Jul 29, 2026
Merged

hanfei1991 merged 1 commit into
ClickHouse:masterfrom
hanfei1991:hanfei/reduce-snapshot-cpu-spike

Conversation

@hanfei1991

@hanfei1991 hanfei1991 commented Jul 28, 2026 •

Copy link
Copy Markdown
Member

See https://github.com/ClickHouse/clickhouse-private/issues/65584

Changelog category (leave one):

  • Improvement

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

Reduce CPU usage when making snapshot for huge amout of files.

Version info

  • Merged into: 26.8.1.383 (included in 26.8 and later)
  • Backported to: 26.7.2.52, 26.6.2.134, 26.5.6.93, 26.3.17.94

@hanfei1991
hanfei1991 requested a review from Diskein July 28, 2026 14:40
@clickhouse-gh

clickhouse-gh Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [53a7b79]

Summary: ✅


AI Review

Summary

This PR tries to reduce the overhead of lightweight snapshot backups by skipping BackupImpl::writeFile for remote entries and only recording the source endpoint / namespace once. The fast path does avoid queueing no-op write jobs, but it also regresses cancellation handling for all-remote snapshots, so I do not think it is ready to merge as-is.

PR Metadata
  • Changelog category should be Performance Improvement, not Improvement, because the change only targets CPU overhead.
  • Changelog entry is required and present, but it is too vague and contains a typo. Suggested replacement: Reduce CPU usage when creating lightweight snapshot backups with many files.
Findings

⚠️ Majors

  • [src/Backups/BackupsWorker.cpp:810] The new isFromRemoteFile() fast path bypasses the only process_list_element->checkTimeLimit() inside writeBackupEntries. For a lightweight snapshot backup whose entries are all remote, a cancellation or time-limit signal after buildFileInfosForBackupEntries() is no longer observed: the loop just continues, runner stays empty, and doBackup() proceeds to finalizeWriting() and can still report BACKUP_CREATED. Put a synchronous cancellation check on this branch as well, for example before the continue, or move the check to the top of the loop so both remote and non-remote entries see it.
Tests
  • ⚠️ Please add a focused regression test that cancels or time-limits a lightweight snapshot after file-info collection has finished and before writeBackupEntries() drains. The test should assert that the operation does not reach BACKUP_CREATED or the snapshot-commit path.
Final Verdict

Changes requested.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Jul 28, 2026
@hanfei1991 hanfei1991 added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Jul 28, 2026
Comment thread src/Backups/BackupsWorker.cpp Resolved
Comment thread src/Backups/IBackup.h Resolved
@clickhouse-gh

clickhouse-gh Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.30% 86.30% +0.00%
Functions 92.10% 92.10% +0.00%
Branches 78.40% 78.40% +0.00%

Changed lines: Changed C/C++ lines covered: 8/13 (61.54%) · Uncovered code

Full report · Diff report

@hanfei1991
hanfei1991 added this pull request to the merge queue Jul 29, 2026
Merged via the queue into ClickHouse:master with commit f31bc84 Jul 29, 2026
178 checks passed
@hanfei1991
hanfei1991 deleted the hanfei/reduce-snapshot-cpu-spike branch July 29, 2026 17:35
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Jul 29, 2026
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 29, 2026
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Jul 29, 2026
hanfei1991 added a commit that referenced this pull request Jul 31, 2026
Backport #112297 to 26.5: Snapshot backup entries should not use backup io thread
hanfei1991 added a commit that referenced this pull request Jul 31, 2026
Backport #112297 to 26.6: Snapshot backup entries should not use backup io thread
hanfei1991 added a commit that referenced this pull request Jul 31, 2026
Backport #112297 to 26.7: Snapshot backup entries should not use backup io thread
hanfei1991 added a commit that referenced this pull request Jul 31, 2026
Backport #112297 to 26.3: Snapshot backup entries should not use backup io thread
UnamedRus pushed a commit to UnamedRus/ClickHouse that referenced this pull request Aug 12, 2026
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Aug 24, 2026
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-improvement Pull request with some product improvements pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR 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