Skip to content

Commit 790cdeb

Browse files
fix: ensure stream is reset on 503 retry in insert loop
1 parent f4a17cd commit 790cdeb

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

  • client-v2/src/main/java/com/clickhouse/client/api

client-v2/src/main/java/com/clickhouse/client/api/Client.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,6 +1556,13 @@ public CompletableFuture<InsertResponse> insert(String tableName,
15561556
if (httpResponse.getCode() == HttpStatus.SC_SERVICE_UNAVAILABLE) {
15571557
LOG.warn("Failed to get response. Server returned {}. Retrying. (Duration: {})", httpResponse.getCode(), durationSince(startTime));
15581558
selectedEndpoint = getNextAliveNode(selectedEndpoint);
1559+
if (i < retries) {
1560+
try {
1561+
writer.onRetry();
1562+
} catch (IOException ioe) {
1563+
throw new ClientException("Failed to reset stream before next attempt", ioe);
1564+
}
1565+
}
15591566
continue;
15601567
}
15611568

0 commit comments

Comments
 (0)