Skip to content

fix NoSuchKey race in NewPlainDiskLayout, stop pooled-env poisoning in plainRewritable tests - #1526

Merged
Slach merged 1 commit into
masterfrom
fix_plain_rewritable_meta_race
Sep 1, 2026
Merged

fix NoSuchKey race in NewPlainDiskLayout, stop pooled-env poisoning in plainRewritable tests#1526
Slach merged 1 commit into
masterfrom
fix_plain_rewritable_meta_race

Conversation

@Slach

@Slach Slach commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Root-caused from the 26.3 job of run 33397256466: 4 of the 5 failures were one cascade.

Fix 1: tolerate a vanished __meta/<token>/prefix.path (pkg/storage/object_disk/plain.go)

NewPlainDiskLayout lists __meta/ and then reads every prefix.path with a separate GetObject. A background merge or a concurrent DROP on the live plain_rewritable disk deletes token directories between the listing and the read, and the whole create failed with NoSuchKey (TestPlainRewritableGCSOverS3 hit exactly this 24s into the scenario, right after inserting 4 small parts that CH immediately merged).

Now a read error is followed by a StatFile probe: if the object is confirmed gone (storage.ErrNotFound), the token is skipped with a warning — ClickHouse building its own path map at startup would not see the directory either. Any other read error still fails the backup. Covered by two new unit tests with a fake RemoteStorage (vanished token skipped; non-not-found stat keeps the fail-loudly behavior).

Fix 2: best-effort DROP DATABASE on scenario failure (test/integration/plainRewritable_test.go)

runPlainRewritableScenario aborted via r.NoError before its DROP DATABASE, returning the pooled env with a leftover database on the plain disk. Every later test acquiring the same env then failed on it: TestRestoreMapping (NoSuchBucket), TestS3NoDeletePermission (AccessDenied for the restricted user), TestAlibabaOverS3 (leftover-files check). A defer now drops the database when the test failed, so one plain-disk failure no longer poisons the pool.

Verified: go vet clean, GOFLAGS= make test exit 0 (17 packages ok), new unit tests pass.

🤖 Generated with Claude Code

…plainRewritable tests

NewPlainDiskLayout lists __meta/ and then reads every prefix.path with a
separate GetObject; a background merge or concurrent DROP on the live
plain_rewritable disk can delete the token directory in between, failing
the whole create with NoSuchKey. Skip a token whose prefix.path is
confirmed gone via StatFile (ClickHouse building its own path map at
startup would not see the directory either); any other read error still
fails the backup.

runPlainRewritableScenario aborted via r.NoError before its DROP
DATABASE, leaving the database on the plain disk in the pooled test env
and cascading into failures of unrelated tests which acquired the same
env (TestRestoreMapping, TestS3NoDeletePermission, TestAlibabaOverS3 in
run 33397256466); drop it best-effort in defer when the test failed.
@Slach Slach added this to the 2.8.1 milestone Aug 31, 2026
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 33414960998

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage increased (+0.06%) to 68.071%

Details

  • Coverage increased (+0.06%) from the base build.
  • Patch coverage: 10 of 10 lines across 1 file are fully covered (100%).
  • 12 coverage regressions across 2 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

12 previously-covered lines in 2 files lost coverage.

File Lines Losing Coverage Coverage
pkg/backup/create.go 10 74.35%
pkg/backup/download.go 2 78.55%

Coverage Stats

Coverage Status
Relevant Lines: 26640
Covered Lines: 18134
Line Coverage: 68.07%
Coverage Strength: 43353.11 hits per line

💛 - Coveralls

@Slach
Slach merged commit e087e2c into master Sep 1, 2026
55 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.

2 participants