-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Snow 1853185 jdbc driver v3.16 native okta http retry storm #2064
base: master
Are you sure you want to change the base?
Snow 1853185 jdbc driver v3.16 native okta http retry storm #2064
Conversation
… into SNOW-1853185-JDBC-Driver-v3.16-Native-Okta-HTTP-Retry-Storm
…ative-Okta-HTTP-Retry-Storm' into SNOW-1853185-JDBC-Driver-v3.16-Native-Okta-HTTP-Retry-Storm
…-HTTP-Retry-Storm
@@ -503,6 +527,9 @@ public static CloseableHttpResponse execute( | |||
requestIdStr, | |||
requestInfoScrubbed, | |||
backoffInMilli); | |||
// TODO: shouldn't we sleep here for backoffInMilli - elapsedMilliForLastCall | |||
// ? | |||
// Thread.sleep(backoffInMilli - elapsedMilliForLastCall); | |||
Thread.sleep(backoffInMilli); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we sleep here for backoffInMilli - elapsedMilliForLastCall?
src/main/java/net/snowflake/client/CallableThrowingSnowflakeSqlException.java
Outdated
Show resolved
Hide resolved
src/main/java/net/snowflake/client/CallableThrowingSnowflakeSqlException.java
Outdated
Show resolved
Hide resolved
src/main/java/net/snowflake/client/CallableThrowingSnowflakeSqlException.java
Outdated
Show resolved
Hide resolved
src/main/java/net/snowflake/client/CallableThrowingSnowflakeSqlException.java
Outdated
Show resolved
Hide resolved
@@ -621,6 +622,24 @@ static String executeRequestWithoutCookies( | |||
new ExecTimeTelemetryData()); | |||
} | |||
|
|||
public static String executeGeneralRequest( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's mark as internal or remove public
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if that's possible - it is still used in multiple places - e.g. in SessionUtil.java
(I gave a longer answer in the next comment to why I kept those)
snowflake-jdbc/src/main/java/net/snowflake/client/core/SessionUtil.java
Lines 1063 to 1069 in 6d5d616
HttpUtil.executeGeneralRequest( | |
postRequest, | |
loginInput.getLoginTimeout(), | |
loginInput.getAuthTimeout(), | |
loginInput.getSocketTimeoutInMillis(), | |
0, | |
loginInput.getHttpClientSettingsKey()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then we can mark some methods with @SnowflakeJdbcInternalApi
* | ||
* @return the retry hook. | ||
*/ | ||
public RetryHook getRetryHook() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to extract the hook? cannot the hook be called indirectly via some method on RetryContextManager?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered the RetryHook Enum as a part of the RetryContext 'interface' - we can specify it in constructor, and adjust outer behavior based on its value later (i.e. when to execute the passed retry logic).
We could consider defining subclasses of the RetryContext class - each representing different type of retry behavior (represented originally by the RetryHook enumeration).
It would be also possible to extract the RetryHook-related data with boolean methods (e.g. isAlwaysRetry() ...) - but I don't think this approach has a significant advantages over the original one)
src/test/java/net/snowflake/client/core/SessionUtilWiremockIT.java
Outdated
Show resolved
Hide resolved
+ vanityUrlCalls.size()); | ||
} | ||
|
||
// Ensure each consecutive pair of calls has at least 1-second gap (1000 ms). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the one second gap configurable? if so let's make it shorter for tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 1-second gap comes from the minimum length of the backoff during retries in RestRequest. It is not configurable from what I understand.
private static final long minBackoffInMilli = 1000; |
src/test/java/net/snowflake/client/core/SessionUtilWiremockIT.java
Outdated
Show resolved
Hide resolved
|
||
// If not found, attempt to read from the classpath (resources directory). | ||
// Has to start from '/' followed by a subdirectory of the resources directory. | ||
try (InputStream in = getClass().getResourceAsStream(filePath)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be simpler?
snowflake-jdbc/src/test/java/net/snowflake/client/jdbc/StreamLatestIT.java
Lines 284 to 289 in 2355c5a
try (InputStream inputStream = | |
conn.unwrap(SnowflakeConnectionV1.class) | |
.downloadStream(stageName, fileName, decompress); | |
InputStreamReader isr = new InputStreamReader(inputStream); | |
BufferedReader br = new BufferedReader(isr)) { | |
String content = br.lines().collect(Collectors.joining("\n")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea - reimplemented this way 👍
…-HTTP-Retry-Storm
Overview
SNOW-1853185
Pre-review self checklist
master
branchmvn -P check-style validate
)mvn verify
and inspecttarget/japicmp/japicmp.html
)SNOW-XXXX:
External contributors - please answer these questions before submitting a pull request. Thanks!
What GitHub issue is this PR addressing? Make sure that there is an accompanying issue to your PR.
Issue: #NNNN
Fill out the following pre-review checklist:
@SnowflakeJdbcInternalApi
(note that public/protected methods/fields in classes marked with this annotation are already internal)Please describe how your code solves the related issue.
Please write a short description of how your code change solves the related issue.