@@ -1499,8 +1499,7 @@ public CompletableFuture<InsertResponse> insert(String tableName, List<?> data,
14991499 lastException = httpClientHelper .wrapException (msg , e , requestSettings .getQueryId ());
15001500 if (httpClientHelper .shouldRetry (e , requestSettings .getAllSettings ()) && requestIsNotCancelled (queryId )) {
15011501 if (i < maxAttempts ) {
1502- LOG .warn ("Retrying." , e );
1503- selectedEndpoint = nodeSelector .getNextAliveNode (selectedEndpoint );
1502+ selectedEndpoint = logRetryAndSelectNextNode ("Insert" , i , maxAttempts , requestSettings .getQueryId (), selectedEndpoint , e );
15041503 } else {
15051504 nodeSelector .getNextAliveNode (selectedEndpoint );
15061505 }
@@ -1705,8 +1704,7 @@ public CompletableFuture<InsertResponse> insert(String tableName,
17051704 lastException = httpClientHelper .wrapException (msg , e , requestSettings .getQueryId ());
17061705 if (httpClientHelper .shouldRetry (e , requestSettings .getAllSettings ()) && requestIsNotCancelled (requestSettings .getQueryId ())) {
17071706 if (i < maxAttempts ) {
1708- LOG .warn ("Retrying." , e );
1709- selectedEndpoint = nodeSelector .getNextAliveNode (selectedEndpoint );
1707+ selectedEndpoint = logRetryAndSelectNextNode ("Insert (stream)" , i , maxAttempts , requestSettings .getQueryId (), selectedEndpoint , e );
17101708 } else {
17111709 nodeSelector .getNextAliveNode (selectedEndpoint );
17121710 }
@@ -1849,8 +1847,7 @@ public CompletableFuture<QueryResponse> query(String sqlQuery, Map<String, Objec
18491847 lastException = httpClientHelper .wrapException (msg , e , requestSettings .getQueryId ());
18501848 if (httpClientHelper .shouldRetry (e , requestSettings .getAllSettings ()) && requestIsNotCancelled (requestSettings .getQueryId ())) {
18511849 if (i < maxAttempts ) {
1852- LOG .warn ("Retrying." , e );
1853- selectedEndpoint = nodeSelector .getNextAliveNode (selectedEndpoint );
1850+ selectedEndpoint = logRetryAndSelectNextNode ("Query" , i , maxAttempts , requestSettings .getQueryId (), selectedEndpoint , e );
18541851 } else {
18551852 nodeSelector .getNextAliveNode (selectedEndpoint );
18561853 }
@@ -1871,6 +1868,19 @@ public CompletableFuture<QueryResponse> query(String sqlQuery, Map<String, Objec
18711868 return runAsyncOperation (responseSupplier , requestSettings .getAllSettings ());
18721869 }
18731870
1871+ /**
1872+ * Logs a single consolidated warning for a failed but retryable request attempt and returns
1873+ * the next endpoint to try. Keeping this in one place ensures a retry is logged exactly once
1874+ * with a consistent shape across the insert and query paths.
1875+ */
1876+ private Endpoint logRetryAndSelectNextNode (String operation , int attemptIndex , int maxAttempts ,
1877+ String queryId , Endpoint endpoint , Exception cause ) {
1878+ LOG .warn ("{} failed (attempt {} of {}, queryId: {}), endpoint: {}, cause: {}: {}. Retrying." ,
1879+ operation , attemptIndex + 1 , maxAttempts + 1 , queryId , endpoint ,
1880+ cause .getClass ().getName (), cause .getMessage ());
1881+ return nodeSelector .getNextAliveNode (endpoint );
1882+ }
1883+
18741884 private void registerTransportReq (String queryId , TransportRequest tr ) {
18751885 if (queryId != null ) {
18761886 ongoingRequests .put (queryId , tr );
0 commit comments