From 69619036fb7506e330a90c117dfe765999906fd8 Mon Sep 17 00:00:00 2001 From: Dominik Przybysz Date: Mon, 27 May 2024 09:48:18 +0200 Subject: [PATCH 1/5] SNOW-1437655: Set auth timeout to 0 in not auth endpoint calls --- src/main/java/net/snowflake/client/core/SFSession.java | 4 ++-- src/main/java/net/snowflake/client/core/SessionUtil.java | 2 +- src/main/java/net/snowflake/client/core/StmtUtil.java | 4 ++-- .../net/snowflake/client/jdbc/telemetry/TelemetryClient.java | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/snowflake/client/core/SFSession.java b/src/main/java/net/snowflake/client/core/SFSession.java index 4547c3caaf..08b81a0f48 100644 --- a/src/main/java/net/snowflake/client/core/SFSession.java +++ b/src/main/java/net/snowflake/client/core/SFSession.java @@ -229,7 +229,7 @@ private JsonNode getQueryMetadata(String queryID) throws SQLException { HttpUtil.executeGeneralRequest( get, loginTimeout, - authTimeout, + 0, (int) httpClientSocketTimeout.toMillis(), maxHttpRetries, getHttpClientKey()); @@ -1136,7 +1136,7 @@ protected void heartbeat() throws SFException, SQLException { HttpUtil.executeGeneralRequest( postRequest, SF_HEARTBEAT_TIMEOUT, - authTimeout, + 0, (int) httpClientSocketTimeout.toMillis(), 0, getHttpClientKey()); diff --git a/src/main/java/net/snowflake/client/core/SessionUtil.java b/src/main/java/net/snowflake/client/core/SessionUtil.java index 38239393ca..bf76f89dec 100644 --- a/src/main/java/net/snowflake/client/core/SessionUtil.java +++ b/src/main/java/net/snowflake/client/core/SessionUtil.java @@ -1377,7 +1377,7 @@ static void closeSession(SFLoginInput loginInput) throws SFException, SnowflakeS HttpUtil.executeGeneralRequest( postRequest, loginInput.getLoginTimeout(), - loginInput.getAuthTimeout(), + 0, loginInput.getSocketTimeoutInMillis(), 0, loginInput.getHttpClientSettingsKey()); diff --git a/src/main/java/net/snowflake/client/core/StmtUtil.java b/src/main/java/net/snowflake/client/core/StmtUtil.java index cde909a18e..cfd85811e1 100644 --- a/src/main/java/net/snowflake/client/core/StmtUtil.java +++ b/src/main/java/net/snowflake/client/core/StmtUtil.java @@ -380,8 +380,8 @@ public static StmtOutput execute(StmtInput stmtInput, ExecTimeTelemetryData exec HttpUtil.executeRequest( httpRequest, stmtInput.networkTimeoutInMillis / 1000, - stmtInput.socketTimeout, 0, + stmtInput.socketTimeout, stmtInput.maxRetries, stmtInput.injectSocketTimeout, stmtInput.canceling, @@ -621,8 +621,8 @@ protected static String getQueryResult(String getResultPath, StmtInput stmtInput return HttpUtil.executeRequest( httpRequest, stmtInput.networkTimeoutInMillis / 1000, - stmtInput.socketTimeout, 0, + stmtInput.socketTimeout, stmtInput.maxRetries, 0, stmtInput.canceling, diff --git a/src/main/java/net/snowflake/client/jdbc/telemetry/TelemetryClient.java b/src/main/java/net/snowflake/client/jdbc/telemetry/TelemetryClient.java index 13b2fb9d2c..1b3e4f6db0 100644 --- a/src/main/java/net/snowflake/client/jdbc/telemetry/TelemetryClient.java +++ b/src/main/java/net/snowflake/client/jdbc/telemetry/TelemetryClient.java @@ -368,7 +368,7 @@ private boolean sendBatch() throws IOException { : HttpUtil.executeGeneralRequest( post, TELEMETRY_HTTP_RETRY_TIMEOUT_IN_SEC, - this.session.getAuthTimeout(), + 0, this.session.getHttpClientSocketTimeout(), 0, this.session.getHttpClientKey()); From c2141cad5b9ff6128f576ebb980a62a5438f080f Mon Sep 17 00:00:00 2001 From: sfc-gh-astachowski Date: Mon, 24 Mar 2025 14:08:38 +0100 Subject: [PATCH 2/5] Remove unnecessary auth timeouts --- src/main/java/net/snowflake/client/core/HttpUtil.java | 4 +--- .../client/jdbc/DefaultResultStreamProvider.java | 2 +- .../client/jdbc/cloud/storage/SnowflakeGCSClient.java | 9 +++------ .../snowflake/client/jdbc/telemetry/TelemetryClient.java | 1 - 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/main/java/net/snowflake/client/core/HttpUtil.java b/src/main/java/net/snowflake/client/core/HttpUtil.java index 8472bf81fd..57be67f401 100644 --- a/src/main/java/net/snowflake/client/core/HttpUtil.java +++ b/src/main/java/net/snowflake/client/core/HttpUtil.java @@ -731,7 +731,6 @@ public static String executeGeneralRequest( * * @param httpRequest HttpRequestBase * @param retryTimeout retry timeout - * @param authTimeout authenticator specific timeout * @param socketTimeout socket timeout (in ms) * @param retryCount max retry count for the request - if it is set to 0, it will be ignored and * only retryTimeout will determine when to end the retries @@ -743,7 +742,6 @@ public static String executeGeneralRequest( public static String executeGeneralRequest( HttpRequestBase httpRequest, int retryTimeout, - int authTimeout, int socketTimeout, int retryCount, CloseableHttpClient httpClient) @@ -752,7 +750,7 @@ public static String executeGeneralRequest( return executeRequestInternal( httpRequest, retryTimeout, - authTimeout, + 0, socketTimeout, retryCount, 0, // no inject socket timeout diff --git a/src/main/java/net/snowflake/client/jdbc/DefaultResultStreamProvider.java b/src/main/java/net/snowflake/client/jdbc/DefaultResultStreamProvider.java index e7a1e8a0ca..667a346e7b 100644 --- a/src/main/java/net/snowflake/client/jdbc/DefaultResultStreamProvider.java +++ b/src/main/java/net/snowflake/client/jdbc/DefaultResultStreamProvider.java @@ -127,7 +127,7 @@ else if (context.getQrmk() != null) { httpClient, httpRequest, context.getNetworkTimeoutInMilli() / 1000, // retry timeout - context.getAuthTimeout(), + 0, context.getSocketTimeout(), 0, 0, // no socket timeout injection diff --git a/src/main/java/net/snowflake/client/jdbc/cloud/storage/SnowflakeGCSClient.java b/src/main/java/net/snowflake/client/jdbc/cloud/storage/SnowflakeGCSClient.java index 40290bd857..1fe646d411 100644 --- a/src/main/java/net/snowflake/client/jdbc/cloud/storage/SnowflakeGCSClient.java +++ b/src/main/java/net/snowflake/client/jdbc/cloud/storage/SnowflakeGCSClient.java @@ -281,7 +281,7 @@ public void download( httpClient, httpRequest, session.getNetworkTimeoutInMilli() / 1000, // retry timeout - session.getAuthTimeout(), + 0, session.getHttpClientSocketTimeout(), getMaxRetries(), 0, // no socket timeout injection @@ -475,7 +475,7 @@ public InputStream downloadToStream( httpClient, httpRequest, session.getNetworkTimeoutInMilli() / 1000, // retry timeout - session.getAuthTimeout(), + 0, session.getHttpClientSocketTimeout(), getMaxRetries(), 0, // no socket timeout injection @@ -670,7 +670,6 @@ public void uploadWithPresignedUrlWithoutConnection( uploadWithPresignedUrl( networkTimeoutInMilli, - 0, // auth timeout (int) HttpUtil.getSocketTimeout().toMillis(), meta.getContentEncoding(), meta.getUserMetadata(), @@ -762,7 +761,6 @@ public void upload( logger.debug("Starting upload with downscope token", false); uploadWithPresignedUrl( session.getNetworkTimeoutInMilli(), - session.getAuthTimeout(), session.getHttpClientSocketTimeout(), meta.getContentEncoding(), meta.getUserMetadata(), @@ -914,7 +912,6 @@ private void uploadWithDownScopedToken( */ private void uploadWithPresignedUrl( int networkTimeoutInMilli, - int authTimeout, int httpClientSocketTimeout, String contentEncoding, Map metadata, @@ -954,7 +951,7 @@ private void uploadWithPresignedUrl( httpClient, httpRequest, networkTimeoutInMilli / 1000, // retry timeout - authTimeout, // auth timeout + 0, httpClientSocketTimeout, // socket timeout in ms getMaxRetries(), 0, // no socket timeout injection diff --git a/src/main/java/net/snowflake/client/jdbc/telemetry/TelemetryClient.java b/src/main/java/net/snowflake/client/jdbc/telemetry/TelemetryClient.java index 1b3e4f6db0..cee84f9ec7 100644 --- a/src/main/java/net/snowflake/client/jdbc/telemetry/TelemetryClient.java +++ b/src/main/java/net/snowflake/client/jdbc/telemetry/TelemetryClient.java @@ -361,7 +361,6 @@ private boolean sendBatch() throws IOException { ? HttpUtil.executeGeneralRequest( post, TELEMETRY_HTTP_RETRY_TIMEOUT_IN_SEC, - 0, (int) HttpUtil.getSocketTimeout().toMillis(), 0, this.httpClient) From c6d69fecccdb53e7c438e09ba4efb3c8b41e6f02 Mon Sep 17 00:00:00 2001 From: sfc-gh-astachowski Date: Mon, 24 Mar 2025 14:43:51 +0100 Subject: [PATCH 3/5] Added deprecated --- src/main/java/net/snowflake/client/core/SFBaseSession.java | 1 + src/main/java/net/snowflake/client/core/SFSession.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/net/snowflake/client/core/SFBaseSession.java b/src/main/java/net/snowflake/client/core/SFBaseSession.java index 15bc3a21db..ecc1281d23 100644 --- a/src/main/java/net/snowflake/client/core/SFBaseSession.java +++ b/src/main/java/net/snowflake/client/core/SFBaseSession.java @@ -1310,6 +1310,7 @@ public SFConnectionHandler getSfConnectionHandler() { /** * @return auth timeout in seconds */ + @Deprecated public abstract int getAuthTimeout(); /** diff --git a/src/main/java/net/snowflake/client/core/SFSession.java b/src/main/java/net/snowflake/client/core/SFSession.java index 08b81a0f48..ae54258cb1 100644 --- a/src/main/java/net/snowflake/client/core/SFSession.java +++ b/src/main/java/net/snowflake/client/core/SFSession.java @@ -109,6 +109,7 @@ public class SFSession extends SFBaseSession { */ private int networkTimeoutInMilli = 0; // in milliseconds + @Deprecated private int authTimeout = 0; private boolean enableCombineDescribe = false; private Duration httpClientConnectionTimeout = HttpUtil.getConnectionTimeout(); From 82d851613b359a1d0fc987632a71eeb233b7dcc4 Mon Sep 17 00:00:00 2001 From: sfc-gh-astachowski Date: Mon, 24 Mar 2025 14:46:11 +0100 Subject: [PATCH 4/5] Reverted breaking change --- src/main/java/net/snowflake/client/core/HttpUtil.java | 4 +++- .../net/snowflake/client/jdbc/telemetry/TelemetryClient.java | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/snowflake/client/core/HttpUtil.java b/src/main/java/net/snowflake/client/core/HttpUtil.java index 57be67f401..8472bf81fd 100644 --- a/src/main/java/net/snowflake/client/core/HttpUtil.java +++ b/src/main/java/net/snowflake/client/core/HttpUtil.java @@ -731,6 +731,7 @@ public static String executeGeneralRequest( * * @param httpRequest HttpRequestBase * @param retryTimeout retry timeout + * @param authTimeout authenticator specific timeout * @param socketTimeout socket timeout (in ms) * @param retryCount max retry count for the request - if it is set to 0, it will be ignored and * only retryTimeout will determine when to end the retries @@ -742,6 +743,7 @@ public static String executeGeneralRequest( public static String executeGeneralRequest( HttpRequestBase httpRequest, int retryTimeout, + int authTimeout, int socketTimeout, int retryCount, CloseableHttpClient httpClient) @@ -750,7 +752,7 @@ public static String executeGeneralRequest( return executeRequestInternal( httpRequest, retryTimeout, - 0, + authTimeout, socketTimeout, retryCount, 0, // no inject socket timeout diff --git a/src/main/java/net/snowflake/client/jdbc/telemetry/TelemetryClient.java b/src/main/java/net/snowflake/client/jdbc/telemetry/TelemetryClient.java index cee84f9ec7..1b3e4f6db0 100644 --- a/src/main/java/net/snowflake/client/jdbc/telemetry/TelemetryClient.java +++ b/src/main/java/net/snowflake/client/jdbc/telemetry/TelemetryClient.java @@ -361,6 +361,7 @@ private boolean sendBatch() throws IOException { ? HttpUtil.executeGeneralRequest( post, TELEMETRY_HTTP_RETRY_TIMEOUT_IN_SEC, + 0, (int) HttpUtil.getSocketTimeout().toMillis(), 0, this.httpClient) From bfb083d782d735041eb90ea49d3fadc5d13bee84 Mon Sep 17 00:00:00 2001 From: sfc-gh-astachowski Date: Mon, 24 Mar 2025 15:06:49 +0100 Subject: [PATCH 5/5] Formatting --- src/main/java/net/snowflake/client/core/SFSession.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/net/snowflake/client/core/SFSession.java b/src/main/java/net/snowflake/client/core/SFSession.java index ae54258cb1..de4bc487ae 100644 --- a/src/main/java/net/snowflake/client/core/SFSession.java +++ b/src/main/java/net/snowflake/client/core/SFSession.java @@ -109,8 +109,7 @@ public class SFSession extends SFBaseSession { */ private int networkTimeoutInMilli = 0; // in milliseconds - @Deprecated - private int authTimeout = 0; + @Deprecated private int authTimeout = 0; private boolean enableCombineDescribe = false; private Duration httpClientConnectionTimeout = HttpUtil.getConnectionTimeout(); private Duration httpClientSocketTimeout = HttpUtil.getSocketTimeout();