Repository navigation
Recognize a broken HTTP stream when fetching Native blobs in test 04819 - #116370
Conversation
The server breaks the HTTP protocol on purpose when a query fails after streaming has started - the terminating chunk is never sent - so `curl` exits with an error instead of passing the poisoned stream off as a result. Fetch every Native blob through a helper that checks this (and `--fail` for a failure before the first byte) and retries, so a transient parallel-replicas teardown race cannot feed exception text into `INSERT ... FORMAT Native` and fail the test with a misleading `Unknown type code` error. #116341 (comment) Co-Authored-By: Claude Fable 5 <[email protected]>
|
Workflow [PR], commit [3932617] Summary: ✅ AI ReviewSummaryThis PR replaces the ad-hoc blob validation in Findings
Final Verdict
|
…her failure Address review: the retry loop in `fetch_blob` masked every non-zero `curl` exit, and the harness runs `.sh` tests without `errexit`, so the final `return 1` let the test keep running on a partial blob. Now only the deliberate mid-stream break (`curl` exit code 18, the transient from issue #116341) is retried; any other failure, or an exhausted retry, aborts the test immediately with the last `curl` error. #116370 Co-Authored-By: Claude Fable 5 <[email protected]>
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]>
| local url="$1" fetch_query="$2" out="$3" error status=0 | ||
| for _ in {1..10} | ||
| do | ||
| error=$($CLICKHOUSE_CURL --fail -sS "$url" --data-binary "$fetch_query" 2>&1 > "$out") && return 0 |
There was a problem hiding this comment.
The new helper only captures curl's stderr. With --fail, an HTTP 500 before the first response byte now collapses to curl: (22) The requested URL returned error: 500 and discards the server's DB::Exception body, so this CI fix still hides the real cause for pre-stream failures. Can we preserve the response body on the non-18 path as well (for example via --fail-with-body plus printing the saved body when status == 22)?
There was a problem hiding this comment.
No problem with that.
Related: #116341
Related: #116342
Related: #112052
Issue #116341 was meanwhile closed by #116342, which deflaked the same fetches with a
fetch_native_blobhelper that greps the blob forDB::Exceptionand sleeps between retries. This PR replaces that helper with the strictercurlexit-code check described below (per the suggestion in the issue): only the deliberate mid-stream break (curlexit code18) is retried, any other failure aborts the test immediately, and the shared-variant fetch that #116342 left raw is guarded too.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Test
04819_dynamic_aggregate_function_state_versionfetchesNativeblobs over HTTP withcurland pipes them intoINSERT ... FORMAT Native, without checking whether the producing query actually succeeded. When a transient error (a parallel-replicas coordinator/replica teardown race,ATTEMPT_TO_READ_AFTER_EOF→UNKNOWN_CODEC) fires after the server has already sent the200header, the exception text lands in the blob file, and the test fails far away from the real cause with a misleadingUnknown type code: 0x61(INCORRECT_DATA).The server already breaks the HTTP protocol on purpose in this case - the terminating empty chunk is never sent (a fixed-length response is cut short the same way) - so
curlrecognizes the poisoned stream and exits with an error (18, transfer closed with outstanding read data remaining), as suggested in #116341 (comment). The test now fetches every blob through afetch_blobhelper that checks thecurlexit code (with--failcovering an error that comes before the first byte) and retries the transient failure up to 10 times; if the fetch keeps failing, the lastcurlerror is printed and fails the test with the real reason.Verified locally against a server with the stateless-test configuration and parallel replicas enabled by default (
default_parallel_replicasover 3 loopback replicas): the test passes repeatedly with and without randomized settings, a mid-stream failure (throwIfafter the first blocks) makescurlexit with code 18 and the helper retries and then reports it, and a pre-stream failure is caught by--failwith exit code 22.The underlying transient (
ATTEMPT_TO_READ_AFTER_EOFinreceivePartitionMergeTreeReadTaskResponseand theUNKNOWN_CODECprotocol desync on the initiator) is not addressed here and may deserve its own investigation, as noted in the issue.Workflow [PR]
Sync PR [sync-upstream/pr/116370]
Version info
26.9.1.370(included in26.9and later)