'How to set a timeout to Phoenix thin driver?
I am developing a microservice with Spring Boot and using the Phoenix thin driver to query a HBase table.
I want to set the timeout to value of 2 minutes but the settings are being ignored:
Properties prop = new Properties();
prop.put(HConstants.HBASE_RPC_TIMEOUT_KEY, "120000");
prop.put(HConstants.HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD, "120000");
prop.put(HConstants.HBASE_RPC_READ_TIMEOUT_KEY, "120000");
prop.put(HConstants.HBASE_CLIENT_RETRIES_NUMBER, "3");
Connection connection = DriverManager.getConnection("jdbc:phoenix:thin:url=http://localhost:8765;serialization=PROTOBUF", prop);
To test this scenario I have started the Phoenix Query Server but not the HBase server. After that, I do a query to HBase through Phoenix waiting to get the timeout after the 2 minutes, but this is not happening.
Perhaps there is a different way to timeout a Phoenix query. If so, I would greatly appreciate the suggestion.
Thank you very much in advance.
Solution 1:[1]
Have you tried setting
phoenix.query.timeoutMs Client-side property specifying the number of milliseconds after which a query will timeout on the client.Default is 10 min. 600000
props.setProperty(QueryServices.THREAD_TIMEOUT_MS_ATTRIB,"600000");
Documented here : https://phoenix.apache.org/tuning.html
QueryServices.java is here : https://github.com/apache/phoenix/blob/master/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
Solution 2:[2]
Hi Ramachandran and thank you so much for your answer.
I tried your suggestion with a timeout value of 10 seconds but the timeout doesn't fire.
props.setProperty(QueryServices.THREAD_TIMEOUT_MS_ATTRIB,"10000");
Connection connection = DriverManager.getConnection("jdbc:phoenix:thin:url=http://localhost:8765;serialization=PROTOBUF", props);
My test scenario was similar to the one described in the original question.
I think the problem is that the Phoenix Query Server keeps trying to connect to HBase for a long time and maybe that's why the driver doesn't trigger the timeout.
Perhaps some configuration is necessary on the Phoenix Query Server.
Do you have any idea that what may be happening?
Thank you very much for your help once again.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ramachandran.A.G |
| Solution 2 | vld |
