datasource query-timeout

Latest response

I'm trying to set a global time out for all queries in a ear application deployed into EAP 7.0.9 application server. The idea is to use the query-timeout setting at datasource level. After I change the xml, I request the configuration of the datasource using jboss-cli

./jboss-cli.sh --connect controller=remote://127.0.0.1:9999 --command=/profile=*/subsystem=datasources/data-source=*:read-resource

"allocation-retry" => undefined,
"allocation-retry-wait-millis" => undefined,
"allow-multiple-users" => false,
"background-validation" => false,
"background-validation-millis" => undefined,
"blocking-timeout-wait-millis" => undefined,
"capacity-decrementer-class" => undefined,
"capacity-decrementer-properties" => undefined,
"capacity-incrementer-class" => undefined,
"capacity-incrementer-properties" => undefined,
"check-valid-connection-sql" => "select 1 from dual",
"connectable" => false,
"connection-listener-class" => undefined,
"connection-listener-property" => undefined,
"connection-url" => "jdbc:oracle:thin:@localhost:1521:pbanker",
"datasource-class" => undefined,
"driver-class" => "oracle.jdbc.OracleDriver",
"driver-name" => "OracleJDBCDriver",
"enabled" => true,
"enlistment-trace" => true,
"exception-sorter-class-name" => undefined,
"exception-sorter-properties" => undefined,
"flush-strategy" => undefined,
"idle-timeout-minutes" => undefined,
"initial-pool-size" => undefined,
"jndi-name" => "java:jboss/datasources/MaxOracleDS",
"jta" => true,
"max-pool-size" => 14,
"mcp" => "org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool",
"min-pool-size" => 5,
"new-connection-sql" => undefined,
"password" => "******",
"pool-fair" => undefined,
"pool-prefill" => undefined,
"pool-use-strict-min" => undefined,
"prepared-statements-cache-size" => undefined,
"query-timeout" => 1L,
"reauth-plugin-class-name" => undefined,
"reauth-plugin-properties" => undefined,
"security-domain" => undefined,
"set-tx-query-timeout" => true,
"share-prepared-statements" => false,
"spy" => false,
"stale-connection-checker-class-name" => undefined,
"stale-connection-checker-properties" => undefined,
"statistics-enabled" => false,
"track-statements" => "NOWARN",
"tracking" => false,
"transaction-isolation" => undefined,
"url-delimiter" => undefined,
"url-selector-strategy-class-name" => undefined,
"use-ccm" => false,
"use-fast-fail" => false,
"use-java-context" => true,
"use-try-lock" => undefined,
"user-name" => "*******",
"valid-connection-checker-class-name" => undefined,
"valid-connection-checker-properties" => undefined,
"validate-on-match" => true,
"connection-properties" => undefined

So, query-timeout and set-tx-query-timeout seem to be setted properly but I don't get any exceptions when a query takes more than 1 second. For example, this query takes more than 10 seconds and there is no timeout exception. I wonder if the timeout works using the entity manager. I even trying to set a hint for the query and I don't get a timeout either

String sql = "Select d from Device d where d.id in (:list)";
TypedQuery<Device> query = getEntityManager().createQuery(sql, Device.class);
query.setParameter("list", subList);
query.setHint("javax.persistence.query.timeout", 50);
List<Device> partialList = query.getResultList();

The database is Oracle 12, I'm using jdbc8 driver.
I don't know what can possible be wrong.

˜˜

Responses