Repository navigation
Conversation
|
Workflow [PR], commit [b4f2c5c] Summary: ✅
AI ReviewSummaryThis PR adds bounded retries for transient Azure Findings❌ Blockers
Tests
Final VerdictStatus: Minimum required actions: protect the remaining auth-failure paths in container creation and Azure copy, finish the batch-delete/single-delete behavior so retryable failures are either retried or at least logged consistently, and add the smallest focused regression coverage for delete/create (or narrow the PR contract if those paths are intentionally out of scope). LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 61/107 (57.01%) · Uncovered code |
| /// A transient per-object 403/auth (RBAC-propagation window): re-issue this single delete | ||
| /// under the bounded retry policy before recording a failure. | ||
| if (isRetryableAzureException(e)) | ||
| { |
There was a problem hiding this comment.
This per-object batch fallback still misses the transient 403 path. isRetryableAzureException(e) here uses the default may_be_provisioning_access = false, so a Forbidden subresponse never reaches the single-object retry path and is logged as a hard delete failure instead.
Please use the same 403/auth retry policy here as the single-object delete path.
b236e30 to
13a0e90
Compare
| /// retryable RequestFailedException (isRetryableAzureException) and a credential AuthenticationException | ||
| /// with bounded exponential backoff, then rethrow. Shared by the GetProperties, delete and copy callers. | ||
| template <typename Func> | ||
| auto retryAzureOperation(Func && func, size_t max_retries, const String & path, const LoggerPtr & log) |
There was a problem hiding this comment.
retryAzureOperation is now the shared correctness point for the new one-shot delete paths, and getBlobPropertiesWithRetry builds on it for exists, metadata reads, and post-upload verification. The only Azure failpoint regression test in tree still exercises merge/read paths (tests/integration/test_azure_403_handling/test.py), so these newly-routed call sites can regress again without any CI signal, which is exactly what happened in the earlier revision of this PR.
Please add focused failpoint integration coverage for at least one GetProperties caller and one delete caller under azure_inject_forbidden_response / azure_inject_auth_failure.
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 99/176 (56.25%) · Uncovered code |
13a0e90 to
c7d6b8c
Compare
c7d6b8c to
a32a18b
Compare
a32a18b to
75fcc6d
Compare
| client.GetProperties(); | ||
| /// No RequestSettings are available at client-factory time; mirror the default retry count. | ||
| retryAzureOnAuthError([&] { return client.GetProperties(); }, | ||
| /*max_retries*/ 3, "containerExists", getLogger("AzureBlobStorageCommon")); |
There was a problem hiding this comment.
containerExists() is still using a hard-coded retry budget of 3, while every other one-shot call site in this PR uses settings->max_single_download_retries (which defaults to azure_max_single_read_retries = 4 and can be overridden per endpoint).
That means a transient AuthenticationException that clears on the 4th attempt still aborts client/disk initialization here even though the later GetProperties() / exists() probes this PR wraps would have succeeded. Since the PR explicitly claims to harden the container-existence check too, this path needs the same configurable budget instead of a separate constant.
75fcc6d to
314b1d5
Compare
| namespace DB | ||
| { | ||
|
|
||
| /// A credential AuthenticationException is thrown by the token layer around the transport, so the SDK |
There was a problem hiding this comment.
retryAzureOnAuthError is introduced as the shared fix for one-shot Azure calls, but AzureObjectStorage::copyObject still goes through copyAzureBlobStorageFile (AzureObjectStorage.cpp:616-646). Inside that helper, the native-copy path (CopyFromUri / StartCopyFromUri) and the upload path (Upload, StageBlock, CommitBlockList) only catch RequestFailedException / StorageException and have no outer ClickHouse retry loop (copyAzureBlobStorageFile.cpp:165-233, 291-339, 395-459).
A transient credential-layer AuthenticationException therefore still aborts blob copies and backup copy flows on the first attempt, which violates the PR's "remaining object-storage call sites" contract. This helper needs to be wired into copyAzureBlobStorageFile too, or the PR contract/tests need to be narrowed to exclude copy paths.
314b1d5 to
b4f2c5c
Compare
| client.GetProperties(); | ||
| /// No RequestSettings are available at client-factory time; mirror the default retry count. | ||
| retryAzureOnAuthError([&] { return client.GetProperties(); }, | ||
| /*max_retries*/ 3, "containerExists", getLogger("AzureBlobStorageCommon")); |
There was a problem hiding this comment.
containerExists is now retried, but the sibling create path in the same factory flow is still one-shot:
service_client->CreateBlobContainer(params.endpoint.container_name)
If the container is absent and that request hits the same transient AuthenticationException / RBAC-propagation window, writable Azure object-storage initialization still fails on the first attempt. This PR is already touching the client-factory probe path, so the create step needs the same auth-retry hardening and budget instead of leaving new-container initialization uncovered.
| retryAzureOnAuthError([&] { buildDataLakeFileClient(path)->Delete(); }, | ||
| settings.get()->max_single_download_retries, path, log); | ||
| success = true; | ||
| } | ||
| else | ||
| { | ||
| auto delete_info = client_ptr->GetBlobClient(path).Delete(); | ||
| auto delete_info = retryAzureOnAuthError([&] { return client_ptr->GetBlobClient(path).Delete(); }, | ||
| settings.get()->max_single_download_retries, path, log); |
There was a problem hiding this comment.
retryAzureOnAuthError can now rethrow AuthenticationException from this single-object delete path after the retry budget is exhausted, but the surrounding handler only catches RequestFailedException.
In that case the function exits before either of the blob_storage_log->addEvent(... Delete ...) calls, so the failed delete leaves no delete record at all on the new auth-retry path. The batch delete path just below already added a broad catch for exactly this reason; single-object deletes need the same logging-before-rethrow treatment (either with an explicit AuthenticationException catch or a shared catch (...) path).
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Object file sizes10 object files changed (+104.86 KiB total), 0 added.
737 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units13 translation units recompiled, 50 s compile time in total, 13 of them have a recent master baseline. |
| { | ||
| return func(); | ||
| } | ||
| catch (const Azure::Core::Credentials::AuthenticationException & e) |
There was a problem hiding this comment.
Sorry I am not clear why we want to retry AuthenticationException ?
We have a function isRetryableAzureException, AuthenticationException is not one of them as this is not usually retryable, but please correct me if I am wrong
|
Dear @SmitaRKulkarni, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
|
Dear @SmitaRKulkarni, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
|
closing as not confirmed |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Retry a transient Azure
AuthenticationException(credential/token-acquisition failure, e.g. during the managed-identity/RBAC propagation window) on object-storage call sites that previously had no retry at all: blob existence/metadata/size probes, single and batch deletes, the post-upload verification, the container existence check, and ADLS Gen2 writes. Previously a single transient credential failure at any of these points failed the whole query or background job.Follow-up to #112871, which handles the HTTP half of the problem: the Azure SDK
RetryPolicynow retries a transient 403 for every client (retry_options.StatusCodes.insert(Forbidden)inAzureBlobStorageCommon.cpp).What the SDK cannot retry is
Azure::Core::Credentials::AuthenticationException: it is thrown by the credential/token layer around the transport, so the retry policy — which only sees HTTP responses andTransportException— never observes it. The read/download/write buffer loops already absorb it via theircatch (...)retry, but these call sites had no retry of any kind:AzureObjectStorage::existsandgetObjectMetadata/getObjectMetadataIfExists— one-shotGetProperties()AzureObjectStorage::removeObjectImpl(blob and ADLS) and the batchSubmitBatchReadBufferFromAzureBlobStorage::tryGetFileSize/getRemoteFileMetadataWriteBufferFromAzureBlobStorage::finalizeImplpost-upload verification — the upload already succeeded, a transient credential failure must not turn a good write into a failurecontainerExistsin the client factory — the first request many flows issueWriteBufferFromAzureDataLakeStorage::runWithRetries— retried HTTP errors but letAuthenticationExceptionescape on the first attemptA single transient credential failure at any of them surfaced as a query/job failure.
Changes:
retryAzureOnAuthError()(src/IO/AzureBlobStorage/retryAzureOnAuthError.h): bounded exponential backoff aroundAuthenticationExceptiononly. HTTP-status retries deliberately stay in the SDK retry policy (Fix transient Azure errors misreported as broken data parts #112871), so retry layers don't stack multiplicatively.getBlobPropertiesWithRetry()lives in the same header for theGetProperties()sites.Azure::Storage::StorageExceptioncatches to the baseAzure::Core::RequestFailedException(a behavior-preserving superset; NotFound handling unchanged).runWithRetriesadditionally retriesAuthenticationExceptionwithin the same budget (shared give-up/backoff tail for both failure kinds).readBigAt: guard against a null body stream in the download response (mirrors the existing guard ininitialize()).test_azure_403_handling): a one-shot injectedAuthenticationExceptionon the direct metadata path (no ClickHouse-level retry loop anywhere) must be absorbed — this test fails without this PR; a permanent one must still fail with the real auth error after the bounded budget.Compared to the previous revision of this PR: all 403/HTTP retrying has been removed from the helper. After #112871 that is the SDK retry policy's job; doing it here as well would stack a second retry loop on top of the SDK's (up to 3 × 11 attempts on a permanent 403). This PR is now strictly about the auth exception the SDK cannot see. The per-object batch re-issue loop is gone for the same reason (an RBAC 403/auth failure is per-principal, i.e. all-or-nothing across a batch; batch-level retry covers it).
Not covered by tests: the ADLS Gen2 write path (azurite cannot emulate ADLS/OneLake endpoints).
Stacked on #112871 (branch base); to be merged after it.