Skip to content

Deflake 04819_dynamic_aggregate_function_state_version: validate and retry the Native blob fetch - #116342

Merged
alexey-milovidov merged 1 commit into
masterfrom
fix/04819-deflake-native-blob-fetch
Aug 26, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
fix/04819-deflake-native-blob-fetch

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Aug 25, 2026 •

Copy link
Copy Markdown
Member

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 to CHANGELOG.md):

Under the ParallelReplicas CI configuration, the blob-producing SELECT ... FORMAT Native over HTTP in 04819_dynamic_aggregate_function_state_version occasionally dies from a transient coordinator/replica teardown race (ATTEMPT_TO_READ_AFTER_EOF in TCPHandler::receivePartitionMergeTreeReadTaskResponse, then UNKNOWN_CODEC on the initiator). HTTP streaming has already sent a 200 by then, so the exception text lands in the blob file and poisons the next INSERT ... FORMAT Native with a confusing Unknown type code: 0x61 (INCORRECT_DATA) — the failure seen sporadically across unrelated PRs since 2026-08-06.

Validate the fetched blob (non-empty, no DB::Exception text) and retry a few times, so only the round trips the test actually checks can fail it. The root-cause chain was reproduced locally with parallel replicas over a 3-loopback-replica cluster and is documented in the linked issue.

Observed on: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=96130&sha=d74faf84e6fcb82b2f5ef56ffe8a280124de9a61&name_0=PR (PR #96130)

Closes: #116341


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

Under the ParallelReplicas CI configuration the blob-producing SELECT can
die from a transient coordinator/replica teardown race
(`ATTEMPT_TO_READ_AFTER_EOF` in `receivePartitionMergeTreeReadTaskResponse`,
then `UNKNOWN_CODEC` on the initiator). HTTP streaming has already sent a
200 by then, so the exception text lands in the blob file and poisons the
next `INSERT ... FORMAT Native` with a confusing
`Unknown type code: 0x61 (INCORRECT_DATA)`. Validate the fetched blob and
retry a few times, so only the round trips the test actually checks can
fail it.

Closes: #116341
@clickhouse-gh

clickhouse-gh Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [5080bdb]

Summary: ✅


AI Review

Summary

This PR tries to deflake 04819_dynamic_aggregate_function_state_version by validating and retrying the HTTP Native blob fetches before the test feeds them back into INSERT ... FORMAT Native. The direction is right, but the fix is incomplete: one later SELECT ... FORMAT Native fetch in the same script still bypasses the new helper, so the same ParallelReplicas teardown race can still poison the blob and reproduce the misleading INCORRECT_DATA failure this PR is meant to remove.

Findings

⚠️ Majors

  • [tests/queries/0_stateless/04819_dynamic_aggregate_function_state_version.sh:67,155-157] The PR's new invariant is "Native blobs fetched over HTTP in this test must be validated and retried before reuse", but the final shared-variant round trip still uses a raw $CLICKHOUSE_CURL fetch. In the ParallelReplicas job that query runs through the same default parallel-replica read path as the earlier dynamic_qd fetches, so the same transient ATTEMPT_TO_READ_AFTER_EOF/UNKNOWN_CODEC response can still be written into 04819_dynamic_shared.native and fail the last round trip with the same misleading INCORRECT_DATA.
    Suggested fix: reuse fetch_native_blob for the dynamic_qd_shared query too, or parameterize the helper by query text so both tables go through the same validation/retry path.
Final Verdict

Not ready: the deflake leaves one remaining unchecked HTTP Native blob fetch on the same flaky path, so it can still fail for the reason the PR claims to eliminate.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Aug 25, 2026
# and the exception text then lands in the blob — HTTP streaming may have already sent a 200 — poisoning
# the next `INSERT` with a confusing `INCORRECT_DATA`. Validate the fetched blob and retry a few times,
# so only the checked round trips can fail the test.
fetch_native_blob()

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.

This helper only hardens the first five SELECT ... FORMAT Native fetches. The later shared-variant round trip still does a raw $CLICKHOUSE_CURL > "$blob" at line 156, and under the ParallelReplicas profile that query goes through the same default parallel-replica read path as the earlier dynamic_qd fetches. That means the same ATTEMPT_TO_READ_AFTER_EOF/UNKNOWN_CODEC response can still be written into 04819_dynamic_shared.native and make shared variant round trip fail with the same misleading INCORRECT_DATA.

Please route the dynamic_qd_shared fetch through the same validation/retry path as well, e.g. by parameterizing fetch_native_blob with the query text instead of closing over the single dynamic_qd query.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's still ok for me.

@alexey-milovidov alexey-milovidov self-assigned this Aug 25, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 25, 2026
Merged via the queue into master with commit 64b4230 Aug 26, 2026
182 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix/04819-deflake-native-blob-fetch branch August 26, 2026 00:23
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 26, 2026
alexey-milovidov added a commit that referenced this pull request Aug 27, 2026
Conflict in `04819_dynamic_aggregate_function_state_version.sh`: master
merged #116342, which deflaked the same fetches with a
`fetch_native_blob` helper that greps the blob for `DB::Exception` and
sleeps between retries. Resolved in favor of this PR's `fetch_blob`
(the `curl` exit-code check suggested in issue #116341), removing the
now-dead `fetch_native_blob`; this PR also guards the shared-variant
fetch that #116342 left raw.

Co-Authored-By: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

2 participants