fivetran-rahulprakash commented on code in PR #3113:
URL: https://github.com/apache/polaris/pull/3113#discussion_r2554771283


##########
polaris-core/src/main/java/org/apache/polaris/core/storage/azure/AzureCredentialsStorageIntegration.java:
##########
@@ -312,16 +314,83 @@ private void validateAccountAndContainer(
         });
   }
 
+  /**
+   * Fetches an Azure access token with timeout and retry logic to handle 
transient failures.
+   *
+   * <p>This method implements a defensive strategy against slow or failing 
token requests:
+   *
+   * <ul>
+   *   <li>15-second timeout per individual request attempt
+   *   <li>Exponential backoff retry (3 attempts: 2s, 4s, 8s) with 50% jitter
+   *   <li>90-second overall timeout as a safety net
+   * </ul>
+   *
+   * @param tenantId the Azure tenant ID
+   * @return the access token
+   * @throws RuntimeException if token fetch fails after all retries or times 
out
+   */
   private AccessToken getAccessToken(String tenantId) {
     String scope = "https://storage.azure.com/.default";;
     AccessToken accessToken =
         defaultAzureCredential
             .getToken(new 
TokenRequestContext().addScopes(scope).setTenantId(tenantId))
-            .blockOptional()
+            .timeout(Duration.ofSeconds(15)) // Per-attempt timeout
+            .doOnError(
+                error ->
+                    LOGGER.warn(
+                        "Error fetching Azure access token for tenant {}: {}",
+                        tenantId,
+                        error.getMessage()))
+            .retryWhen(
+                Retry.backoff(3, Duration.ofSeconds(2)) // 3 retries: 2s, 4s, 
8s
+                    .jitter(0.5) // ±50% jitter to prevent thundering herd
+                    .filter(
+                        throwable ->
+                            throwable instanceof 
java.util.concurrent.TimeoutException

Review Comment:
   Yes, you're absolutely right! I missed that. Removed the duplicate check 
now. Thank you for catching that!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to