【问题标题】:How to set a timeout to Phoenix thin driver?如何为 Phoenix 瘦驱动程序设置超时?
【发布时间】:2022-01-26 16:29:32
【问题描述】:

我正在使用 Spring Boot 开发一个微服务,并使用 Phoenix 瘦驱动程序来查询 HBase 表。

我想将超时设置为 2 分钟,但设置被忽略:

    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);

为了测试这个场景,我启动了 Phoenix Query Server,但没有启动 HBase 服务器。之后,我通过 Phoenix 向 HBase 查询,等待 2 分钟后超时,但这没有发生。

也许有另一种方法可以让 Phoenix 查询超时。如果是这样,我将不胜感激。

非常感谢您。

【问题讨论】:

    标签: timeout hbase phoenix


    【解决方案1】:

    你试过设置吗

    phoenix.query.timeoutMs   Client-side property specifying the number of milliseconds after which a query will timeout on the client.
    

    默认为 10 分钟。 600000

       props.setProperty(QueryServices.THREAD_TIMEOUT_MS_ATTRIB,"600000");
    

    在此处记录:https://phoenix.apache.org/tuning.html

    QueryServices.java 在这里:https://github.com/apache/phoenix/blob/master/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java

    【讨论】:

    • 您好 Ramachandran,我在您的回答中添加了一个新问题/评论。我是新来的,我不知道,因为它在上面。谢谢!
    【解决方案2】:

    您好 Ramachandran,非常感谢您的回答。

    我尝试了您的建议,超时值为 10 秒,但超时没有触发。

    props.setProperty(QueryServices.THREAD_TIMEOUT_MS_ATTRIB,"10000");
    Connection connection = DriverManager.getConnection("jdbc:phoenix:thin:url=http://localhost:8765;serialization=PROTOBUF", props);
    

    我的测试场景与原始问题中描述的类似。

    我认为问题在于 Phoenix Query Server 一直尝试连接到 HBase 很长时间,也许这就是驱动程序没有触发超时的原因。

    可能需要在 Phoenix Query Server 上进行一些配置。

    您知道会发生什么吗?

    再次感谢您的帮助。

    【讨论】:

      猜你喜欢
      • 2010-11-07
      • 1970-01-01
      • 2012-11-03
      • 2014-02-16
      • 2019-11-06
      • 2010-11-04
      • 1970-01-01
      • 1970-01-01
      • 2018-10-02
      相关资源
      最近更新 更多