Skip to content

fix: better error message about missing download.state2 file#1385

Merged
Slach merged 4 commits into
Altinity:masterfrom
leno23:hermes-auto/clickhouse-backup-1383-resume-missing-state
May 29, 2026
Merged

fix: better error message about missing download.state2 file#1385
Slach merged 4 commits into
Altinity:masterfrom
leno23:hermes-auto/clickhouse-backup-1383-resume-missing-state

Conversation

@leno23
Copy link
Copy Markdown
Contributor

@leno23 leno23 commented May 17, 2026

Summary

  • allow download --resume to continue when the local backup directory exists but download.state2 is missing
  • keep the existing resume warning when the state file is present and log a clearer warning for resume-from-scratch
  • add a regression test covering the missing-state-file resume path

Tests

  • go test ./pkg/backup -run TestResumeExistingBackupAllowsMissingStateFile -count=1
  • go test ./pkg/backup -count=1

Closes #1383

Treat download.state2 as optional for --resume so an existing backup
directory without state can be validated and resumed from scratch.
@Slach Slach added this to the 2.7.1 milestone May 22, 2026
Copy link
Copy Markdown
Collaborator

@Slach Slach left a comment

Choose a reason for hiding this comment

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

See #1383 (comment) — auto-fallback to scratch download when download.state2 is missing is not safe (silent corruption risk: no way to know which local files are complete vs cut mid-stream). The acceptable fix is improving the error message to point at clickhouse-backup delete local <name>, not changing the behavior. Not merging this as-is.

Comment thread pkg/backup/download.go
return ErrBackupIsAlreadyExists
} else {
_, checkDownloadErr := os.Stat(path.Join(b.DefaultDataPath, "backup", backupName, "download.state2"))
if errors.Is(checkDownloadErr, os.ErrNotExist) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

better return here following error

local backup '<name>' exists but download.state2 is missing.
  run `clickhouse-backup delete local <name>` and retry,
  or investigate why the resumable state was lost.

@Slach Slach marked this pull request as ready for review May 29, 2026 11:11
@Slach Slach changed the title fix: allow resume without download state file fix: better error message without download.state2 file May 29, 2026
@Slach Slach changed the title fix: better error message without download.state2 file fix: better error message about missing download.state2 file May 29, 2026
@Slach Slach merged commit fd917bd into Altinity:master May 29, 2026
54 of 56 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.

better error message --resume crash when download.state2 file is missing

2 participants