Repository navigation
Fix transient Azure errors misreported as broken data parts - #112871
Conversation
|
Workflow [PR], commit [88ea678] Summary: ✅
AI ReviewSummaryThis PR reclassifies transient Azure Final Verdict✅ No blocking issues found. LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 71/76 (93.42%) · Uncovered code |
80a4c93 to
e9d9c93
Compare
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 40/51 (78.43%) · Uncovered code |
Build profile diff (arm_release)No arm_release build profile data for commit 88ea678 - the build was skipped, reused from cache, or predates profile upload. |
The base branch (arsenmuk/az-transient-not-broken-part, #112871) rewrote the 403/auth/timeout failpoints and the integration test after this PR was cut, so merge it in and re-express the batch-delete test against the new conventions (clean_state fixture, azure_inject_forbidden_response, azure_policy). Address the two review comments on the batch-delete change: - removeObjectsBatchIfExists now preserves the real Azure HTTP status in the batch-failure blob_storage_log Delete events (catch StorageException -> e.StatusCode), matching the per-object path; -1 is kept only for non-Azure failures (e.g. a credential AuthenticationException). - The test asserts one failed Delete event per object, scoped to the dropped table's own blobs and to error_code = 403, instead of a global count() > 0.
The SDK RetryPolicy retries transient HTTP errors (including 403 after #112871) but never sees Azure::Core::Credentials::AuthenticationException: it is thrown by the credential layer around the transport. Retry it with bounded backoff at the call sites that have no ClickHouse-level retry loop: existence/metadata/size probes, single and batch deletes, the post-upload verification, the container existence check, and ADLS Gen2 writes. HTTP-status retries deliberately stay in the SDK retry policy so the two retry layers do not stack multiplicatively.
…-checkdatapart-rethrow Resolve the moved base (the #112871 test suite was rewritten). Re-express the CHECK TABLE regression in the new suite as a plain-MergeTree test pinning the StorageMergeTree::checkDataNext caller, and fix the transposed name/message args in checkDataPart's retryable-error log line.
77e50f7 to
f9d6177
Compare
Previously `isRetryableAzureException` only treated HTTP 403 as retryable when `may_be_provisioning_access=true`, which was only set by `IDisk::checkAccessImpl` for the initial startup access check. As a result, after a credential or role change, the brief permission-propagation window caused in-flight SELECTs to fail. Worse, `MergeTreeSequentialSource::generate`'s `catch (...)` invoked `reportBrokenPart`, and `StorageSharedMergeTree::reportBrokenPart`'s `catch (...)` reclassified the Azure exception as `POTENTIALLY_BROKEN_DATA_PART`, which triggers loud alerting via `ForcedCriticalErrorsLogger` even though the underlying part is fine. Treat 403 as retryable in all callers. A genuinely permanent 403 still surfaces: in-buffer retries are bounded, and the final failure is reported as a plain Azure error rather than a phantom broken part. The `is_initial_access_check` flag is retained for its other job (bumping `max_unexpected_write_error_retries` 3x at startup). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
f9d6177 to
88ea678
Compare
| return response; | ||
|
|
||
| /// Throw TransportException (retryable) for a timeout instead of a synthetic 408 that read as a broken part. | ||
| throw Azure::Core::Http::TransportException(getCurrentExceptionMessageAndPattern(true).text); |
There was a problem hiding this comment.
I see that logic here is changed from
return to throw.
What stands behind this change?
From the code for S3 I see that return might be retried in sdk, but throw is not retried in sdk, exception goes to the clickhouse read buffer code.
There was a problem hiding this comment.
Do I understand it correct, that you make 403/408 errors retryable for isRetryableException in src/Storages/MergeTree/checkDataPart.cpp and in src/Disks/IO/WriteBufferFromAzureBlobStorage.cpp
but it would be not retriable in the SDK?
There was a problem hiding this comment.
If I'm right, then you would not get a time on retries with fallbacks on such case, the query will fail fast, but the part would not be marked as broken.
BTW: The retries in the read buffer do not give you the right retries. Read buffer retries strange cases which we were not able to handle in the right palace back then, or the cases when SDK behaves wrong. There is a few retries count max_unexpected_write_error_retries=4.
Here I do not like that there is an inconsistency: it is written here and there that this error is retryable but it is retryable not anywhere.
You actually ended up in the solution when you made errors not retryable and not falty in the same time. Before this PR all not retryable errors were falty.
With this PR: all retryable errors are not faulty. Some not retryable errors are not falty also. The rest not retryable errors are faulty. Faulty errors are the errors which triggers a part to be broken.
But you did not write that classification to the code. That leads as to the state when we have retryable errors without retries.
There was a problem hiding this comment.
@groeneai check my conclusion here.
And answer the question:
How would 403/408 errors be retried in this PR? Who retry them, how, how much?
There was a problem hiding this comment.
I checked the Azure SDK, and this one does retry the throw. I'm wrong here. This error would be just retryable.
There was a problem hiding this comment.
Thank you for the questions. We just discussed offline a bit, and agreed on your latest conclusion - leaving it as is here, as the error will be retried via exception
There was a problem hiding this comment.
@CheSema Measured on this branch, azure disk, default settings.
403 after this PR. Two nested layers, neither of which covered 403 before:
- The SDK
RetryPolicy. Its defaultStatusCodesis{408, 500, 502, 503, 504}(azure-core/.../policies/policy.hpp:133), so 403 was excluded; this PR inserts it (AzureBlobStorageCommon.cpp:404). Budgetazure_sdk_max_retries=10: 11 attempts, 10ms doubling capped at 1000ms, about 4.3s. - The read loop at
ReadBufferFromAzureBlobStorage.cpp:137,azure_max_single_read_retries=4, backoff 100/200/400ms.
They nest rather than overlap, because PocoAzureHTTPClient::Send makes one attempt and leaves retrying to the pipeline (PocoHTTPClient.cpp:143). So a permanent 403 on a read becomes up to 44 HTTP requests over roughly 14-23s (jitter 0.8-1.3). On master that same 403 fails on the first request, since isRetryableAzureException returns true only under may_be_provisioning_access, and the reader's catch then calls reportBroken() (MergeTreeReaderWide.cpp:76). So it is not fail-fast as your second comment supposed; the cost is latency, not missing retries.
408. Already in the SDK default set. The PR replaces the synthetic 408 with a TransportException, which RetryPolicy catches explicitly (retry_policy.cpp:157) on the same budget. That agrees with your correction.
Your conclusion. I agree on the substance: the taxonomy is three-valued and written down nowhere. checkDataPart.h:19 declares isRetryableException with no comment, and 20 call sites across 10 files consume it.
Your "retryable without retries" case does still hold for one class, the one this PR adds: Azure::Core::Credentials::AuthenticationException. It derives from std::exception, not RequestFailedException (credentials.hpp:137), so isRetryableAzureException never sees it, and RetryPolicy catches only TransportException, so the SDK does not retry it either, even though the bearer-token policy that throws it runs inside the retry loop (pipeline.hpp:124, then :128). It is retried only where a ClickHouse loop has a catch-all, meaning the read and write buffers. AzureObjectStorage::exists, getObjectMetadata and listObjects have none, so there it is classified retryable and retried zero times.
Your last comment. Poco::Net::NetException derives from Poco::IOException, so both reach the catch-all at PocoHTTPClient.cpp:515 and become a synthetic 500 (:525). 500 is retryable at both layers, so the retries are right; the loss is diagnostic, since connection-refused becomes indistinguishable from a server-side 500. S3 keeps them apart, mapping each to NETWORK_CONNECTION (S3/PocoHTTPClient.cpp:757-770).
One note on the description: I found no thrower of POTENTIALLY_BROKEN_DATA_PART (740) in master. It occurs only at ErrorCodes.cpp:622 and in Exception::isErrorCodeImportant (Exception.cpp:302). The master outcome I could verify for these errors is reportBroken() queueing the part for check, not a 740 reaching the client.
Adjacent from my side: #114180 covers the not-found (404) class on the part-load path, which this PR does not touch.
| /// Throw TransportException (retryable) for a timeout instead of a synthetic 408 that read as a broken part. | ||
| throw Azure::Core::Http::TransportException(getCurrentExceptionMessageAndPattern(true).text); | ||
| } | ||
| catch (...) |
There was a problem hiding this comment.
here also could be:
Poco::Net::NetException
Poco::IOException
Poco::TimeoutException -- you handle it, ok
const NetException
Here they are substituded with InternalServerError.
S3 considered them as retriable network errors.
There was a problem hiding this comment.
But I understand that you might consider it out of scope for this PR
There was a problem hiding this comment.
I'll add this as a follow-up. Thank you!
…rors makeRequestInternalImpl caught client-side transport failures only via the terminal catch(...), turning them into a synthetic InternalServerError(500) response. Add catch(const Poco::IOException&) — covering the whole Poco::Net::NetException family (connection reset/refused, DNS, TLS) plus generic IO — and catch(const NetException&) for ClickHouse's own DB::NetException(DNS_ERROR) from makeHTTPSession, which is not a Poco::IOException. Both mirror the existing Poco::TimeoutException arm and throw Azure::Core::Http::TransportException, so network errors are retried unconditionally by the SDK rather than relying on 500 being in the retryable status set (matches the S3 client at src/IO/S3/PocoHTTPClient.cpp). Add azure_inject_poco_network_error[_once] failpoints and a "network" case in the test_azure_403_handling suite. Follow-up to ClickHouse#112871, addresses review comment ClickHouse#112871 (comment)
Backport #112871 to 26.7: Fix transient Azure errors misreported as broken data parts
…orted as broken data parts
On master the Azure transport now throws `TransportException` for a timeout or a broken connection (ClickHouse#112871, ClickHouse#115269) instead of returning a synthetic 408 or 500 from `PocoAzureHTTPClient`. `TransportException` carries no status code, so the status-only classifier reported a timed-out rename as a definite failure ("Rename failed: HTTP 0") and the destructor then claimed the file was unchanged, although the rename may have been applied. The classifier now takes the exception and treats a transport failure as ambiguous, which yields "commit status unknown" as for 408 and 5xx. A transport failure is also rendered with its explanation, which is in `what` rather than `Message`, instead of as `HTTP 0: `, and it is logged to `system.blob_storage_log` with a non-zero error code through `getAzureErrorCodeForLog`, as `WriteBufferFromAzureBlobStorage` does. `isRetryableAzureException` now retries a 403 unconditionally (ClickHouse#112871), so a 403 on the staging create is retried on the same staging name. The test for that path now checks that only one staging name is used, which is what it is about, rather than the number of requests. The test's request classifier now uses `contains`, which clang-tidy 22, the compiler version master pins now, requires. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Problem. Transient Azure errors — a
403(Forbidden), a credentialAuthenticationException, and connect timeouts (surfaced as a synthetic408) — were previously classified as non-retryable, which caused healthy data parts to be flagged as corrupt:POTENTIALLY_BROKEN_DATA_PART(code 740). Due to Azure RBAC propagation lag, these 403s are possible within minutes after service provisioning. They are not always caught byIDisk::checkAccess(), because that startup probe and the later data requests can be served by different Azure storage frontends holding different (stale) RBAC caches.Fix. Treat 403/408 as retryable and throw a real
TransportExceptionfor connect timeouts (instead of fabricating a 408), so the read path retries in-budget and a transient failure is never attributed to data corruption.Changes.
IO/AzureBlobStorage/isRetryableAzureException: 403 + 408 retryable; drop themay_be_provisioning_accessarg.IO/AzureBlobStorage/PocoHTTPClient: throwAzure::Core::Http::TransportExceptiononPoco::TimeoutExceptioninstead of a synthetic 408.Disks/DiskObjectStorage/ObjectStorages/AzureBlobStorage/AzureBlobStorageCommon: add403to the Azure SDK's retryable status codes — its default set omits it — so call sites without a ClickHouse-level retry loop are covered too.Storages/MergeTree/checkDataPart(isRetryableException): treatAuthenticationExceptionas retryable.Common/FailPoint+tests/integration/test_azure_403_handling: failpoints and regression tests for transient vs permanent 403 / auth / timeout, plus a non-retryable error as a negative control.Scope note.
isRetryableAzureExceptionno longer takesmay_be_provisioning_access, so 403 is retryable at every call site, including writes; previously it was retryable only forIDisk::checkAccess()(#86419). Budgets stay bounded, so a permanent 403 still fails — now after the full budget (~18s on a read) instead of immediately. This also fixes the read half ofcheckAccess, which had no 403 tolerance at all. @tavplubix @alesapin — asking you to confirm this widening, as owners of the 403 gate and of the Poco HTTP client respectively.Supersedes #111179 (same 408 fix), closed in favour of this — thanks @qiuyanjun888.
Closes #106298, #110724.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed a transient Azure Blob Storage error on the read or merge path — an RBAC permission-propagation
403 Forbidden, a credential authentication failure, or a connect timeout surfaced as408— being misclassified as non-retryable and reported asPOTENTIALLY_BROKEN_DATA_PART(Code 740), raising a false critical alert for a healthy part. These transient failures are now treated as retryable, and a genuinely persistent one surfaces as a plain Azure error instead of a phantom broken data part.Version info
26.8.1.1265-master(included in26.8and later)26.7.23.6