Skip to content

S3Queue: clear stale .retriable marker on terminal failure and skip terminalization while processing - #125565

Open
adityaksolves wants to merge 22 commits into
ClickHouse:masterfrom
adityaksolves:feature/s3queue-stale-retriable-cleanup
Open

adityaksolves wants to merge 22 commits into
ClickHouse:masterfrom
adityaksolves:feature/s3queue-stale-retriable-cleanup

Conversation

@adityaksolves

@adityaksolves adityaksolves commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Related: #113054
Depends on #121752 (the diff also shows #121752's commits until it is merged; the new commits here are a35f313, 80815bd and 6e593ea).

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

S3Queue: when a file fails permanently, its leftover .retriable retry marker is now cleared, a file that is still being processed is no longer marked as permanently failed, and lowering loading_retries is now honored immediately by files that were already queued for retry.

Detailed description

This is a follow-up PR from the split of #113784. It covers the stale .retriable cleanup item.

Problem:

  • On terminal failure, /failed/<hash> was created but the .retriable marker was not removed, so both nodes could exist together.
  • tryTerminalizeExhaustedRetriableMarker() could terminalize a marker while /processing/<hash> still existed, i.e. while the file was being processed.
  • Retry-limit checks compared against the max_loading_retries value captured at construction time, so a FileMetadata reused via FileIterator::returnForRetry() could miss a later decrease of loading_retries and hand out one extra processing attempt.

Fix:

  • On terminal failure, the .retriable marker is cleared in the same Keeper multi-op that removes the processing node and creates /failed/<hash>.
  • tryTerminalizeExhaustedRetriableMarker() returns false if /processing/<hash> exists.
  • isRetriableMarkerExhausted, hasNonProcessableState, trySetProcessing and prepareSetProcessingRequests now compare against the live loading_retries_ref.load() instead of the construction-time max_loading_retries snapshot (6e593ea).

Tests (test_failed_files_ttl.py):

  • test_terminal_failure_clears_stale_retriable_marker
  • test_processing_path_blocks_retriable_terminalization

Known limitation: the processing-node existence check and the terminalization multi-op are separate Keeper operations, so a narrow race window remains. This PR does not claim to remove it completely.

Verification status: both tests fail without the fix, with the expected assertions. They have not yet been verified green with the fix; CI results are pending.

Not in this PR


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

Adds the failed_files_ttl_sec engine setting, which controls time-based
expiry of terminal failed files in unordered mode. tracked_files_limit's
description is also updated to document that it caps the failed-files
set by count in both ordered and unordered mode, independently of the
new setting.

For tables created before this setting existed, the value is inherited
from tracked_file_ttl_sec at attach time; this inheritance is a one-time
fallback and is not kept in sync with later changes to tracked_file_ttl_sec.
…ck in hash-ring path; fix retriable marker test helper
Cover clearing the .retriable marker on terminal failure, and skipping terminalization of an exhausted marker while /processing/<hash> exists.
@clickhouse-gh

clickhouse-gh Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [f5e0703]

Summary: ✅


AI Review

Summary

At f5e07031d24ec3da2b58a5672be64e8d901768a1, this PR clears stale .retriable markers on terminal failure, avoids terminalization when a processing owner is observed, and reads retry limits live. The full diff includes the unmerged #121752. A newly identified upgrade regression and unresolved wait semantics prevent approval; deferred findings below remain present in the reviewed code.

Findings

❌ Blockers

⚠️ Majors

Tests
  • ⚠️ Cover legacy ordered-queue retention with a single failed file and no count cap, then repair the file and verify ingestion resumes after expiry. The existing legacy-metadata test covers only unordered mode.
  • ⚠️ Cover lowering the retry limit during a paused retry that subsequently succeeds; SYSTEM FLUSH OBJECT STORAGE QUEUE ... PATH must wait and succeed. The current processing-node test does not exercise the wait path.
  • ⚠️ Provide a focused before/after measurement for healthy claim batches with hash-ring filtering enabled. No such evidence accompanies the additional serial Keeper reads.
Final Verdict

Status: ❌ Block. Preserve legacy ordered TTL behavior, carry both wait corrections into the reviewed stack, batch claim-side marker reads, and make the processing-owner regression deterministic. These corrections may land in the dependency where appropriate, but must be present in the resulting diff before approval.

@clickhouse-gh clickhouse-gh Bot added the pr-feature Pull request with new product feature label Oct 14, 2026
@adityaksolves

Copy link
Copy Markdown
Contributor Author

@nihalzp Config Workflow is failing on the latest run (commit 6e593ea) in the Check CI DB step (connection refused to play.clickhouse.com), so all other jobs are DROPPED. The previous run on 80815bd passed this step, so this looks like a transient CI infrastructure issue. Could you please re-run the workflow? Thanks!

@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default and removed pr-feature Pull request with new product feature labels Oct 14, 2026
Comment on lines +1054 to +1059
if not zk.exists(planted_processing_path):
zk.create(
planted_processing_path,
b"test-processing-owner",
makepath=True,
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Major — The test can adopt the real worker's transient processing node

The materialized view is still retrying this file when this check runs. If zk.exists sees a real retry's processing node, the test skips creating its own node; after the limit is lowered, that worker legitimately fails, removes its processing node, and clears the marker. The assertions after the three-second wait then fail even with the fix. If the node is absent, the worker can also claim it between exists and create, producing NodeExistsError.

Please synchronize the retry worker before establishing this precondition, or pause a real in-flight retry and explicitly wait for that pause. The test must know that its processing owner remains present until it releases the owner; sampling a transient node and waiting a fixed duration does not establish that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Noted. I will make the owner synchronization deterministic if the test turns out flaky in CI.

@nihalzp

nihalzp commented Oct 14, 2026

Copy link
Copy Markdown
Member

@adityaksolves For such issues, you can push a new commit to rerun the CI.

This branch has not been deployed

No deployments
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-s3queue S3Queue/AzureQueue engines (queue-based ingestion from object storage). external Author is not a member of the ClickHouse organization pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants