Skip to content

Stress test: ignore benign filesystem-cache background-download No such key - #108489

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/stress-ignore-cachemetadata-bg-download-nosuchkey
Jun 28, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/stress-ignore-cachemetadata-bg-download-nosuchkey

Conversation

@groeneai

@groeneai groeneai commented Jun 25, 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

The stress critical-error scan flags benign filesystem-cache background-download No such key errors as lost s3 keys.

The filesystem cache background-download worker (CacheMetadata, src/Interpreters/FileCache/Metadata.cpp) continues prefetching a partially-downloaded file segment. Under stress the underlying S3 object can be concurrently removed (DROP, mutation, part removal), so the GET returns Code: 499 NoSuchKey. The worker catches this, marks the segment download failed and logs Error during background download (no rethrow); the data is simply re-read from the source later, so it is benign.

tests/docker_scripts/stress_tests.lib greps for Code: 499 ... The specified key does not exist and already excludes the foreground form of this event (ReadBufferFromS3, AsynchronousBoundedReadBuffer, ReadBuffer is canceled by the exception), but not the background-download form, so it was reported as S3_ERROR No such key thrown.

This adds Error during background download to the grep -v allowlist, following the precedent of the existing exclusions. The token is unique to the CacheMetadata background-download log line (Metadata.cpp:824), so a genuinely lost key reported from any other path is still flagged.

Chronic trunk failure: ~10 distinct unrelated PRs + 1 master hit over 30 days, ~1 occurrence each.

Example CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=108441&sha=cdabef4635c981dd60507f49d1307f9f7dc4d62a&name_0=PR&name_1=Stress%20test%20%28arm_release%29

Server log line:

<Error> CacheMetadata: Error during background download of <hash>:4194304 (File segment: [4194304, 8388607], ..., state: PARTIALLY_DOWNLOADED_NO_CONTINUATION, ..., background download: 1): Code: 499. DB::Exception: The specified key does not exist. ... (S3_ERROR)

Version info

  • Merged into: 26.7.1.207 (included in 26.7 and later)

…ch key

The filesystem cache background-download worker (CacheMetadata,
src/Interpreters/FileCache/Metadata.cpp) continues prefetching a
partially-downloaded file segment. Under stress the underlying S3 object can
be concurrently removed (DROP, mutation, part removal), so the GET returns
Code: 499 NoSuchKey. The worker catches this, marks the segment download
failed and logs "Error during background download"; the data is simply
re-read from the source later, so it is benign.

The stress critical-error scan greps for "Code: 499 ... specified key does not
exist" and already excludes the foreground form of this event (ReadBufferFromS3,
AsynchronousBoundedReadBuffer, "ReadBuffer is canceled by the exception"), but
not the background-download form, so it was flagged as a lost s3 key.

Add "Error during background download" to the grep -v allowlist. The token is
unique to the CacheMetadata background-download log line, so a genuinely lost
key reported from any other path is still flagged.
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Pure grep-pattern fix, no build needed. The exact CI log line (<Error> CacheMetadata: Error during background download ... Code: 499 ... The specified key does not exist (S3_ERROR)) is fed through the harness grep -v allowlist: OLD allowlist lets it through (=FAIL, reproduces CI); patched allowlist excludes it.
b Root cause explained? Yes. The filesystem-cache background-download worker (CacheMetadata::downloadThreadFunc/downloadImpl, src/Interpreters/FileCache/Metadata.cpp) keeps prefetching a PARTIALLY_DOWNLOADED_NO_CONTINUATION segment. Under stress the underlying S3 object is concurrently removed (DROP/mutation/part removal), so the GET returns Code 499 NoSuchKey. It is caught at Metadata.cpp:816, the segment is marked setDownloadFailed() and logged as Error during background download (no rethrow); the data is re-read directly later, so it is benign. The harness greps Code: 499.*The specified key does not exist and already excludes the foreground form (ReadBufferFromS3, AsynchronousBoundedReadBuffer, "ReadBuffer is canceled by the exception") but not the background-download form.
c Fix matches root cause? Yes. Adds Error during background download to the same grep -v allowlist that already tolerates the foreground form of this exact concurrency event, following the precedent of commits 5a92eb6 / 96f073f ("exception printed internally by a buffer, exception will be rethrown and handled correctly").
d Test intent preserved / new tests added? Yes. The check still flags a genuinely lost key reported from any other path. Verified: a sample executeQuery: Code: 499 ... while reading key: REAL/lost/key line is STILL flagged after the patch. The excluded token is unique to Metadata.cpp:824 (grep-confirmed, single occurrence in the tree).
e Both directions demonstrated? Yes. Extracted the patched file's actual grep -v invocation and ran it on a sample log: benign background-download line excluded; genuine lost-key line still flagged. bash -n syntax OK.
f Fix is general across code paths? N/A (CI-harness allowlist change, not a code bug). The single background-download log site is the only path that emits this benign message; the foreground sibling paths are already excluded.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (CI-harness allowlist change, not a code bug).
h Backward compatible? N/A (CI-harness allowlist change, not a code bug). No setting/format/validation change.
i Invariants and contracts preserved? N/A (CI-harness allowlist change, not a code bug). The patch only narrows which benign log lines the stress critical-error scan reports; the genuine-lost-key invariant is preserved (unique token).

Session id: cron:clickhouse-worker-slot-0:20260625-132900

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @antonio2368 — could you review this? It extends the stress critical-error grep -v allowlist you set up in 5a92eb6 / 96f073f to also ignore the filesystem-cache background-download form of a benign concurrent No such key (CacheMetadata marks the prefetch failed and re-reads directly). The foreground form (ReadBufferFromS3 etc.) is already excluded; the added token is unique to the background-download log line so genuinely lost keys are still flagged.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jun 25, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [0cdd9b7]

Summary: ❌

job_name test_name status info comment
Stress test (arm_asan_ubsan) FAIL
Hung check failed, possible deadlock found FAIL cidb, issue ISSUE EXISTS

AI Review

Summary
  • This PR narrows the stress-test critical-error scan by allowing the known benign CacheMetadata background-download NoSuchKey log line while preserving detection for other Code: 499 / The specified key does not exist logs. I verified the modified grep keeps a representative real lost-key line, filters the background-download line, and the script still parses.
Missing context / blind spots
  • ⚠️ The published CI report for commit 0cdd9b746ee8a37aeae4dc174ae0f0fcf639ec8e currently contains no test results, so I could not validate this through an actual stress job result. A stress run that hits or replays the affected log line would close this gap.
Final Verdict
  • Status: ✅ Approve

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 0cdd9b7

Every failure below has an owner.

Check / test Reason Owner / fixing PR
Stress test (arm_asan_ubsan) / Hung check failed, possible deadlock found deadlock #101680 / #105905 (ours, open)

Session id: cron:our-pr-ci-monitor:20260625-190000

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sounds good.

I expect it happens when the filesystem cache is used for ordinary files on S3 (the s3 table function or engine, rather than MergeTree tables).

@alexey-milovidov alexey-milovidov self-assigned this Jun 28, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jun 28, 2026
Merged via the queue into ClickHouse:master with commit 94a3653 Jun 28, 2026
165 of 167 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 28, 2026
pull Bot pushed a commit to Spencerx/ClickHouse that referenced this pull request Jul 29, 2026
…No such key

The "Lost s3 keys" / "S3_ERROR No such key thrown" checks of the functional
tests jobs report the filesystem cache background download worker error as a
lost object. The worker (CacheMetadata) keeps prefetching a partially
downloaded file segment whose remote object can be concurrently removed
(DROP, mutation, part removal), so the GET returns Code: 499 NoSuchKey, the
download is marked as failed and the data is re-read from the source later -
nothing is lost.

tests/docker_scripts/stress_tests.lib already ignores this line (ClickHouse#108489), the
functional tests checks did not, so `Stateless tests (*, s3 storage, *)` failed
with all tests green.

Both checks run the same scan, so the ignore list is built once. Also removed
an accidentally duplicated "Lost forever for SharedMergeTree" check.
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…nore-cachemetadata-bg-download-nosuchkey

Stress test: ignore benign filesystem-cache background-download No such key
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 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