Skip to content

add --disk-limit to download and config option general -> download_disk_limit - #1543

Merged
Slach merged 4 commits into
masterfrom
disk_limit_1458
Sep 9, 2026
Merged

add --disk-limit to download and config option general -> download_disk_limit#1543
Slach merged 4 commits into
masterfrom
disk_limit_1458

Conversation

@Slach

@Slach Slach commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

fix #1458

Slach and others added 4 commits September 9, 2026 13:35
#1458

The free-space checks (#878, #1268) only guarantee the download fits,
so a download can still fill a data disk to 100% and take
clickhouse-server down. `--disk-limit <pct>` (CLI) and `disk_limit`
(API) refuse the download when (used + downloaded) / total of any local
disk would exceed the limit; 0 or absent keeps the current behavior.

The check reuses the #1268 estimate, which already honors --tables and
--partitions, and extends it with a per-disk breakdown. Parts of a disk
missing in system.disks are attributed to the least-used local disk the
same way the download rebalances them; object-disk parts are not counted
against local disks. `system.disks.total_space` is now read into
`Disk.TotalSpace`; disks without it are skipped with a warning. Resume
downgrades the error to a warning like the existing checks.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
#1458

`download_disk_limit` (DOWNLOAD_DISK_LIMIT) sets the disk usage limit
once in config.yml, `--disk-limit` still overrides it per command and
the API `disk_limit` parameter behaves the same way.

A download refused by the disk-limit or free-space check used to leave
table metadata and the resumable state behind; with the default
`use_resumable_state: true` the next run of the same command resumed
and the refusal degraded to a warning, so the guard was bypassed by
simply retrying. Remove what the refused run wrote when it was not a
resume itself.

Manual.md and the "Common CLI Usage" section of ReadMe.md are
regenerated by generate_manual.sh.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Use env.dropDatabase helper instead of a raw DROP DATABASE query for
consistent teardown, and update the testflows CLI snapshot to include
the new download_disk_limit default config field.
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 34348178468

Coverage decreased (-0.04%) to 66.901%

Details

  • Coverage decreased (-0.04%) from the base build.
  • Patch coverage: 23 uncovered changes across 3 files (73 of 96 lines covered, 76.04%).
  • 45 coverage regressions across 6 files.

Uncovered Changes

File Changed Covered %
pkg/server/server.go 26 8 30.77%
pkg/backup/download.go 58 54 93.1%
pkg/backup/list.go 1 0 0.0%
Total (6 files) 96 73 76.04%

Coverage Regressions

45 previously-covered lines in 6 files lost coverage.

File Lines Losing Coverage Coverage
pkg/storage/general.go 17 68.77%
pkg/storage/gcs.go 15 55.58%
pkg/clickhouse/clickhouse.go 5 79.58%
pkg/backup/download.go 4 77.78%
pkg/backup/backuper.go 2 77.67%
pkg/storage/structs.go 2 81.82%

Coverage Stats

Coverage Status
Relevant Lines: 25771
Covered Lines: 17241
Line Coverage: 66.9%
Coverage Strength: 35612.91 hits per line

💛 - Coveralls

@Slach
Slach merged commit 7d55e23 into master Sep 9, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add --disk-limit protection with table-filtered download size estimation

2 participants