Skip to content

fix: propagate incremental download failures to waiting workers - #1704

Open
compiler-segfault wants to merge 1 commit into
Altinity:masterfrom
compiler-segfault:fix/incremental-download-error-waiters
Open

compiler-segfault wants to merge 1 commit into
Altinity:masterfrom
compiler-segfault:fix/incremental-download-error-waiters

Conversation

@compiler-segfault

@compiler-segfault compiler-segfault commented Nov 30, 2026 •

Copy link
Copy Markdown

An exhausted download of a required incremental-backup archive can leave restore_remote in progress indefinitely. downloadDiffRemoteFile returns on the error without unlocking its per-file mutex; a subsequent caller waits on that mutex while holding the cache mutex. Thanks to @vgproskurin for the report and the independent Docker reproducer.

Replace the cached mutex with a completion channel and the download result. The owner publishes its error on every return path, including resume-state write failures. Cached callers wait outside the map lock and can return when their own context is cancelled. Successful cached calls still return zero downloaded bytes. Merely deferring the old unlock would allow these callers to return success after a failed download.

Fixes #1681.

Validation on Linux/amd64, Go 1.27.0, against baseline abc187421f56c3c67bb8a64e2ae37892a2a1f037:

  • go test ./pkg/backup -run TestDownloadDiffRemoteFile -count=10 -timeout=120s
  • go test -race ./pkg/backup -run TestDownloadDiffRemoteFile -count=10 -timeout=180s
  • go vet ./..., go test ./... -count=1 -timeout=300s, and gofmt checks.
  • The regression covers archive and directory downloads, cached errors, concurrent success/error waiters, cancellation without cancelling the owner, another archive progressing while a waiter is pending, and successful deduplication/byte accounting. On the baseline, eight subtests fail and the two normal download controls pass (only the cache value type is adapted to compile against the old signature). An unlock-only baseline mutation fails both cached-error cases by returning nil.
  • The unchanged public reproducer at 664a269d663f45b4bf53b12e14ac697c1c5f98f9 reproduces the hang with both the published 2.8.3 image and a binary built from the pinned baseline: two completed truncated responses, no active faulty responses, and two blocked mutex waiters. Substituting the patched binary into the same 2.8.3 container returns an action error containing the original unexpected EOF, with zero blocked waiters. A separate no-fault control restores all 12,544 rows with the original data fingerprint.
  • A separate wrapper then runs the original fault case, disables the fault, and retries the same backup through the same running server. The retry succeeds and restores the original 12,544-row fingerprint without restarting the server.

The Docker check uses ClickHouse 26.8.36.3, SeaweedFS 4.00 and the reporter's synthetic fixture. It does not establish results for other ClickHouse versions or cloud services; the repository's separately tagged integration matrix was not run locally.

Follow-up on the ClickHouse 26.3 CI failure: I replayed the first local create/drop/restore sequence from TestInnerTablesMaterializedView against the pinned baseline and this PR on ClickHouse 26.3.75.5 with the same ON CLUSTER schema-restore setting. Both returned code 60 for the missing test_mv.src_table. With the source table included in the backup, both restored 100 rows in each view. This was an isolated replay of the failing local sequence, without the S3 portion of the CI test.

AI disclosure: This patch, regression tests and PR text were prepared autonomously by OpenAI Codex under the account owner's authorization. Codex ran the checks described above; no human code review is claimed. The report and public reproducer are the reporter's work.

@Slach Slach added this to the 2.8.4 milestone Nov 30, 2026
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.

Incremental restore hangs after an archive download from the backup chain fails

2 participants