在 JBoss 中使用连接池时 postgres 查询超时问题

postgres query timeout issue while using connection pooling in JBoss

我面临以下问题

ERROR: canceling statement due to user request 

在我的 xxx-ds.xml 中为 xa 数据源启用查询超时后不一致。我在 ds xml 文件中添加了以下内容。

 <query-timeout>180</query-timeout>

在搜索 Whosebug 时发现 this 问题,其中讨论了使用连接池时出现此问题的可能原因。

建议的解决方案是在 postgresql.conf 文件中设置 statement_timeout 设置。但是我很难在我的数据库环境中启用 statement_timeout 设置,因为数据库服务器由多个应用程序共享。 我希望有一个解决方案可以在使用连接池时有效且一致地终止来自客户端的超时查询。我正在使用

看来问题出在 postgresql 驱动程序 9.2 上。当我升级到 9.3 时,问题已解决。