Skip to content

Fix flaky test_database_backup: skip the S3 disk startup access check - #124184

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-test-database-backup-s3-access-check
Oct 10, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-test-database-backup-s3-access-check

Conversation

@groeneai

@groeneai groeneai commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

Description

All 14 test_database_backup tests failed in start_cluster in Integration tests (amd_llvm_coverage, 6/8), reported in #123069 (comment). instance_local_metadata exited at startup because the access check of disk backup_disk_s3_plain got 403 AccessDenied from MinIO, although it uses the MinIO root user.

Root cause: it is neither MinIO readiness nor user setup. Both servers load the same configs/backups.xml and run the startup access check (PUT, GET, DELETE of a probe object) in the same fresh, otherwise empty prefix at the same time. MinIO's DELETE removes the now-empty parent directories while the other server's PUT is creating them, and MinIO maps the resulting mkdir ENOENT to AccessDenied (renameAll in cmd/os-reliable.go, via isSysErrPathNotFound). In the CI log the denied PUT failed 0.5 ms after the other server's DELETE completed. The code is unchanged in the latest MinIO release, so an image bump does not help.

I reproduced it without ClickHouse against the same MinIO image: two clients doing PUT/GET/DELETE of unique probes in an empty prefix got 7 and 13 AccessDenied PUTs in two 120 s runs (about 45k PUTs each), and 0 of 49876 when one extra object kept the prefix non-empty.

Fix: skip_access_check on backup_disk_s3_plain, as in #110300 and #110592. The disk is still used by the tests, so a broken disk config still fails at first use. Server logs confirm 0 probe writes on that disk with the change (1 per server without it); the module passed all 4 local runs (14/14 each).

Other modules that start several MinIO-backed servers share this shape. The ENOENT to AccessDenied mapping is a MinIO bug; I can report it to pgsty/silo (the project the image mirrors) if that is useful.


Workflow [PR]
Sync PR [sync-upstream/pr/124184]

Version info

  • Merged into: 26.10.1.2039-master (included in 26.10 and later)

Both servers of the module (`instance` and `instance_local_metadata`, the
second added in 88a9fbd) load `configs/backups.xml` and run the
`IDisk::startup` access check of `backup_disk_s3_plain` (PUT, GET, DELETE of
`clickhouse_access_check_<uuid>`) at the same time, in the same fresh MinIO
prefix `root/data/disks/disk_s3_plain/` that holds nothing but the two
probes.

MinIO's DELETE removes the object directory and then every now-empty parent
(`cmd/xl-storage.go`, `deleteFile`), while the other server's PUT creates the
same parents in `RenameData -> renameAll -> reliableRename ->
reliableMkdirAll` (`cmd/os-reliable.go`). When a parent is removed between
its EEXIST and the child's mkdir, `os.Mkdir` returns an ENOENT PathError,
and `renameAll` classifies it with `isSysErrPathNotFound` (non-Windows branch
is `pathErr.Err == ENOENT`, `cmd/xl-storage-errors.go`) as
`errFileAccessDenied`, i.e. `403 AccessDenied`, even for the root user. The
code is unchanged in the latest pgsty/silo release.

In the failing job (PR ClickHouse#123069, amd_llvm_coverage 6/8) the denied PUT was
sent at 14:11:26.619465 and failed at .624049, 0.47 ms after `instance`'s
DELETE of its own probe completed (.622793-.623583); the server exited and
all 14 tests failed in `start_cluster`. Two clients doing the same
PUT/GET/DELETE against the same MinIO image locally got 7 and 13
AccessDenied PUTs in two 120 s runs with an empty prefix, and 0 of 49876
with one extra object keeping the prefix non-empty.

With `skip_access_check` neither server writes to MinIO at startup; the
disk is still used by every BACKUP/RESTORE in the module. Same remedy as
ClickHouse#110300 and ClickHouse#110592.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai labels Oct 6, 2026
@groeneai

groeneai commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 1 finding) plus my own cold review (1 nit).

# Sev Finding Verdict Evidence / action
1 ⚠️ No oracle proves the startup probe on backup_disk_s3_plain is suppressed (configs/backups.xml) DISAGREE Server logs over every retained start: 0 probe writes with the line (instance 11 starts, instance_local_metadata 3, in each of 3 runs), 1 per server with it reverted; the sibling local disk's probe is logged at every start. Module 14/14 in 4 runs.
2 💡 PR description declined the MinIO-side fix without offering it AGREE, fixed before publication Description now offers to report it to pgsty/silo.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding.

Session id: cron:clickhouse-review-slot-10:20261006-092300

@clickhouse-gh

clickhouse-gh Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [37617ca]

Summary: ✅


AI Review

Summary

This PR makes test_database_backup stop probing backup_disk_s3_plain during server startup by adding skip_access_check in tests/integration/test_database_backup/configs/backups.xml:13. That matches the current disk-startup plumbing: s3_plain uses the shared object-storage disk creator, the flag suppresses only the startup checkAccess call, and the disk is still initialized normally and exercised later by the Disk('backup_disk_s3_plain', ...) backup cases in tests/integration/test_database_backup/test.py. I reviewed the current diff, the prior PR discussion, and the cited failing integration report, and I did not find blocker- or major-level issues in the change.

Final Verdict

✅ Looks good to merge.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 6, 2026
@groeneai
groeneai requested a review from pamarcos October 6, 2026 09:42
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Oct 6, 2026
@alexey-milovidov alexey-milovidov self-assigned this Oct 10, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 10, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

@groeneai I'll merge this. But the right solution is - all access checks should use a random file name (not just with the server uuid, but unique). You can send a follow-up PR.

@groeneai

Copy link
Copy Markdown
Collaborator Author

Acknowledged, I'll send a follow-up PR that makes the disk access checks use a unique random file name. Note that this alone would not have prevented this failure: the two servers already used different names (clickhouse_access_check_a2271f61... and clickhouse_access_check_e6428b16...), and my standalone MinIO repro still gets the 403 with a fresh random name for every probe, because one server's DELETE prunes the shared empty parent prefix while the other's PUT is creating it.

Merged via the queue into ClickHouse:master with commit 1a7c64c Oct 10, 2026
149 of 150 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 10, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

Follow-up PR: #125098

alexey-milovidov pushed a commit to mneedham/ClickHouse that referenced this pull request Oct 11, 2026
`IDisk::checkAccess` named its probe after the server UUID, so the name
was unique only per server identity: two servers with the same `uuid`
file (one data directory copied from the other) that share a disk
location, such as an S3 prefix, and check it at the same time write,
read and delete the same file, and one delete can fail the other's
reads.

Name the probe from a fresh random UUID per check, as the other two disk
probes (`DiskLocalCheckThread` and `IDisk::isCaseInsensitive`) already
do. The `clickhouse_access_check_` prefix is kept, so prefix-scoped
bucket policies keep working. The Nil-server-UUID guard goes with the
dependency: both programs that run startup checks load the UUID before
any disk starts.

Follow-up to ClickHouse#124184 (comment)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added comp-backup Backup/restore infrastructure and backup formats. and removed comp-testing Test content only (no production code). labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-backup Backup/restore infrastructure and backup formats. groeneai-origin-request PR origin: a maintainer pinged or directed groeneai pr-ci 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.

3 participants