-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
[HIVE-26336] Introduce a new JDBC parameter connectTimeout #3379
Conversation
* Source Iceberg PR - Core: Remove deprecated APIs up to 0.13.0 * Revert "HIVE-25563: Iceberg table operations hang a long time if metadata is missing/corrupted (Adam Szita, reviewed by Marton Bod)" - applying instead Hive: Limit number of retries when metadata file is missing (apache#3379) This reverts commit 7b600fe. * Source Iceberg PR - Hive: Limit number of retries when metadata file is missing (apache#3379) * Source Iceberg PR - Hive: Fix RetryingMetaStoreClient for Hive 2.1 (apache#3403) * Source Iceberg PR - Switch from new HashMap to Maps.newHashMap (apache#3648) * Source Iceberg PR - Hive: HiveCatalog should remove HMS stats for certain engines based on config (apache#3652) - Use the Iceberg config property * Source Iceberg PR - Core: If status check fails, commit should be unknown (apache#3717) * Source Iceberg PR - Build: Add checkstyle rule for instantiating HashMap, HashSet, ArrayList (apache#3689) * Source Iceberg PR - Test: Make sure to delete temp folders (apache#3790) * Source Iceberg PR - API: Register existing tables in Iceberg HiveCatalog (apache#3851) * Source Iceberg PR - Hive: Make Iceberg table filter optional in HiveCatalog (apache#3908) * Source Iceberg PR - Core: Add reserved UUID Table Property and Expose in HMS. (apache#3914) * Source Iceberg PR - Hive: Known exception should not become CommitStateUnknownException (apache#4261) * Source Iceberg PR - Build: Add missing @OverRide annotations (apache#3654)
@prasanthj @pvary would you please take a look? |
It would be good to create unit tests to define the expected behaviour and prevent changes in it |
Let me try to add a unit test. (Not sure if easy because it's network-related) |
Thread conn2 = new Thread(run); | ||
conn1.start(); | ||
conn2.start(); | ||
assertEquals(goodCounter.get(), 1); |
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.
Couldn't this become flaky, if the getConnection
is slow?
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.
WIP: I can not compile Hive on M1 machine, just push and finding a x86 machine...
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 sorry I can not compile and run the test even on an x86 machine, the IDEA is stuck on building hive-exec module... and I simplified the test to check the variable initialization only, please let me know if this is sufficient or not.
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 would like to see some test where we make sure that no future change will break the loginTimeout
, socketTimeout
behaviour.
Not sure about your env, but we sometime create virtual machines and run our tests there to have a linux env. This might help you too if you have access to some env.
stmt.execute("SELECT reflect('java.lang.Thread', 'sleep', 3000L)"); | ||
} | ||
} catch (Exception exception) { | ||
badCounter.incrementAndGet(); |
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.
Are we sure that this is the exception what we expect here?
Passed test on x86 machine, #3377 may helpful for fixing M1 building.
|
} | ||
|
||
@Test | ||
public void testLoginTimeoutDoesNotAffectSocketTime() throws Exception { |
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.
This test does not fail before the PR
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.
It should fail before HIVE-12371, HIVE-12371 changes behavior but does not provide test
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.
Actually, I don't know how to test loginTimeout
, does Hive have something like "session init sql"?
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.
Could you use simple jdbc connection?
miniHS2.getJdbcURL()
could provide the jdbc url to connect to the running HS2 server
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 guess there is no difference because HiveConnection invokes openSession in the constructor
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.
As for the testing I have found this:
https://stackoverflow.com/questions/100841/artificially-create-a-connection-timeout-error
Not sure if it's suitable, from my understanding, it can be used to test socket timeout but not connect timeout. Because the server must accept the connection and establish a TCP connection before reading a parameter(sleep=6000) passed by HTTP protocol.
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 think it make sense to use DriverManager.loginTimeout as connectTimeout but not socketTimeout. Comparing login or connect, a query may take hours, that is why users report socket timeout exceptions.
Was this loginTimeout used anywhere else? Do we need to keep backward compatibility?
As for the testing I have found this:
https://stackoverflow.com/questions/100841/artificially-create-a-connection-timeout-errorNot sure if it's suitable, from my understanding, it can be used to test socket timeout but not connect timeout. Because the server must accept the connection and establish a TCP connection before reading a parameter(sleep=6000) passed by HTTP protocol.
We can have different tests. One for the connectTimeout, and one for the socketTimeout, and set the other to a value which does not interfere with the test.
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.
Was this
loginTimeout
used anywhere else?
I think no, the IDEA index indicates it is not used by others.
Do we need to keep backward compatibility?
I think not necessary, the old implementation does not right. HIVE-12371 has already broken it one time.
To clarify I think we have 3 approaches for improving the "*timeout" stuff
- Introduce new JDBC parameter
connectTimeout
w/ exsitingsocketTimeout
, ignoreDriverManager.loginTimeout
- Same as 1, but use
DriverManager.loginTimeout
asconnectTimeout
ifconnectTimeout
absent. - Introduce new JDBC parameter
loginTimeout
andconnectTimeout
w/s exsitingsocketTime
, useloginTimeout
assocketTimeout
for openSession request, and resetsocketTimeout
if openSession successful.
Which one do you prefer?
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 would go with the 1st approach
Also set the DriverManager.loginTimeout
to @deprecated
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.
Thanks for the confirmation, will implement it in the next few days.
itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcTimeout.java
Outdated
Show resolved
Hide resolved
Implement it as we discussed before, but I found it is not easy to add integration tests. The following tests are what I want to add at first, but finally, I realized it does not make sense, because JDBC always runs in async mode, a "sleep" query will not block the server return the response immediately.
|
### _Why are the changes needed?_ There are two concepts `connect timeout` and `so timeout` in the socket, currently, the Kyuubi Hive JDBC driver uses `DriverManager#loginTimeout` as both of them, it does not make sense, and will cause unexpected "read timeout" exceptions if `DriverManager#loginTimeout` was set a small value, e.g. Spring Boot set it to 30s in default. This PR proposes to introduce two dedicated JDBC parameters to control them. See also apache/hive#3379 ### _How was this patch tested?_ - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible - [ ] Add screenshots for manual tests if appropriate - [x] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request Closes #3152 from pan3793/timeout. Closes #3152 5dcae66 [Cheng Pan] nit 816a851 [Cheng Pan] nit 3b5e6ce [Cheng Pan] fix npe 4cb73df [Cheng Pan] Introduce JDBC parameters to control connection timeout Authored-by: Cheng Pan <chengpan@apache.org> Signed-off-by: Cheng Pan <chengpan@apache.org>
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
* Source Iceberg PR - Core: Remove deprecated APIs up to 0.13.0 * Revert "HIVE-25563: Iceberg table operations hang a long time if metadata is missing/corrupted (Adam Szita, reviewed by Marton Bod)" - applying instead Hive: Limit number of retries when metadata file is missing (apache#3379) This reverts commit 7b600fe. * Source Iceberg PR - Hive: Limit number of retries when metadata file is missing (apache#3379) * Source Iceberg PR - Hive: Fix RetryingMetaStoreClient for Hive 2.1 (apache#3403) * Source Iceberg PR - Switch from new HashMap to Maps.newHashMap (apache#3648) * Source Iceberg PR - Hive: HiveCatalog should remove HMS stats for certain engines based on config (apache#3652) - Use the Iceberg config property * Source Iceberg PR - Core: If status check fails, commit should be unknown (apache#3717) * Source Iceberg PR - Build: Add checkstyle rule for instantiating HashMap, HashSet, ArrayList (apache#3689) * Source Iceberg PR - Test: Make sure to delete temp folders (apache#3790) * Source Iceberg PR - API: Register existing tables in Iceberg HiveCatalog (apache#3851) * Source Iceberg PR - Hive: Make Iceberg table filter optional in HiveCatalog (apache#3908) * Source Iceberg PR - Core: Add reserved UUID Table Property and Expose in HMS. (apache#3914) * Source Iceberg PR - Hive: Known exception should not become CommitStateUnknownException (apache#4261) * Source Iceberg PR - Build: Add missing @OverRide annotations (apache#3654)
* Source Iceberg PR - Core: Remove deprecated APIs up to 0.13.0 * Revert "HIVE-25563: Iceberg table operations hang a long time if metadata is missing/corrupted (Adam Szita, reviewed by Marton Bod)" - applying instead Hive: Limit number of retries when metadata file is missing (apache#3379) This reverts commit 7b600fe. * Source Iceberg PR - Hive: Limit number of retries when metadata file is missing (apache#3379) * Source Iceberg PR - Hive: Fix RetryingMetaStoreClient for Hive 2.1 (apache#3403) * Source Iceberg PR - Switch from new HashMap to Maps.newHashMap (apache#3648) * Source Iceberg PR - Hive: HiveCatalog should remove HMS stats for certain engines based on config (apache#3652) - Use the Iceberg config property * Source Iceberg PR - Core: If status check fails, commit should be unknown (apache#3717) * Source Iceberg PR - Build: Add checkstyle rule for instantiating HashMap, HashSet, ArrayList (apache#3689) * Source Iceberg PR - Test: Make sure to delete temp folders (apache#3790) * Source Iceberg PR - API: Register existing tables in Iceberg HiveCatalog (apache#3851) * Source Iceberg PR - Hive: Make Iceberg table filter optional in HiveCatalog (apache#3908) * Source Iceberg PR - Core: Add reserved UUID Table Property and Expose in HMS. (apache#3914) * Source Iceberg PR - Hive: Known exception should not become CommitStateUnknownException (apache#4261) * Source Iceberg PR - Build: Add missing @OverRide annotations (apache#3654)
i think this pr can be reopen. in somecase connection timeout is different from socketTimeout. |
What changes were proposed in this pull request?
Introduce a new JDBC parameter
connectTimeout
.Why are the changes needed?
Before HIVE-12371, the Hive JDBC Driver uses DriverManager#loginTimeout as both connectTimeout and socketTimeout, which usually cause socket timeout exception to users who use Hive JDBC Driver in Spring Boot project, because Spring Boot will setLoginTimeout to 30s (default value).
HIVE-12371 introduced a new parameter
socketTimeout
to replaceloginTimeout
, and does not care about DriverManager#loginTimeout anymore.This PR proposes to add a new JDBC parameter
connectTimeout
Does this PR introduce any user-facing change?
Yes. New JDBC parameter
connectTimeout
is introduced.How was this patch tested?
New test added, and pass the existing UT.