-
Bug
-
Resolution: Done
-
Major
-
None
-
None
-
None
set-tx-query-timeout setting does not work when the remaining transaction timeout is shorter than one second (between 0-999 millis) due to incorrect round-up in IronJacamar WrapperDataSource#getTimeLeftBeforeTransactionTimeout().
—
WrappedConnection#checkConfiguredQueryTimeout() checks the returned value from WrapperDataSource#getTimeLeftBeforeTransactionTimeout() and set the value to query timeout if it's larger than 0. If it's not larger than 0, the configured query timeout (query-timeout in datasource setting) is used. This behavior itself is ok.
However, WrapperDataSource#getTimeLeftBeforeTransactionTimeout() incorrectly rounds up the returned value from transaction manager's TransactionTimeoutConfiguration#getTimeLeftBeforeTransactionTimeout(). And it results in returning 0 when the remaining transaction timeout is between 0-999 millis. This causes the issue.
Here's the related code from 1.3.7.Final (It's same in the latest 1.3 branch and 1.4 branch):
- https://github.com/ironjacamar/ironjacamar/blob/ironjacamar-1.3.7.Final/adapters/src/main/java/org/jboss/jca/adapters/jdbc/WrappedConnection.java#L2022-L2049
2022 /** 2023 * Check configured query timeout 2024 * @param ws The statement 2025 * @param explicitTimeout An explicit timeout value set 2026 * @exception SQLException Thrown if an error occurs 2027 */ 2028 void checkConfiguredQueryTimeout(WrappedStatement ws, int explicitTimeout) throws SQLException 2029 { 2030 if (mc == null || dataSource == null) 2031 return; 2032 2033 int timeout = 0; 2034 2035 // Use the transaction timeout 2036 if (mc.isTransactionQueryTimeout()) 2037 { 2038 timeout = dataSource.getTimeLeftBeforeTransactionTimeout(); 2039 if (timeout > 0 && explicitTimeout > 0 && timeout > explicitTimeout) 2040 timeout = explicitTimeout; 2041 } 2042 2043 // Look for a configured value 2044 if (timeout <= 0 && explicitTimeout <= 0) 2045 timeout = mc.getQueryTimeout(); 2046 2047 if (timeout > 0) 2048 ws.setQueryTimeout(timeout); 2049 }
- https://github.com/ironjacamar/ironjacamar/blob/ironjacamar-1.3.7.Final/adapters/src/main/java/org/jboss/jca/adapters/jdbc/WrapperDataSource.java#L190-L218
190 /** 191 * Get the time left before a transaction timeout 192 * @return The amount in seconds; <code>-1</code> if no timeout 193 * @exception SQLException Thrown if an error occurs 194 */ 195 protected int getTimeLeftBeforeTransactionTimeout() throws SQLException 196 { 197 try 198 { 199 if (cm instanceof TransactionTimeoutConfiguration) 200 { 201 long timeout = ((TransactionTimeoutConfiguration) cm).getTimeLeftBeforeTransactionTimeout(true); 202 // No timeout 203 if (timeout == -1) 204 return -1; 205 // Round up to the nearest second 206 long result = timeout / 1000; 207 if ((result % 1000) != 0) 208 ++result; 209 return (int) result; 210 } 211 else 212 return -1; 213 } 214 catch (RollbackException e) 215 { 216 throw new SQLException(e); 217 } 218 }
- is cloned by
-
JBEAP-13300 [GSS](7.1.z) set-tx-query-timeout does not work when the remaining transaction timeout is shorter than one second
- Closed
- is duplicated by
-
JBEAP-13714 [GSS](7.2.0) set-tx-query-timeout does not work when the remaining transaction timeout is shorter than one second
- Closed
-
JBJCA-1309 Query timeout (set-tx-query-timeout) not applied within last second before transaction timeout
- Closed
- is incorporated by
-
WFLY-9659 Upgrade Ironjacamar to 1.4.7
- Closed
- relates to
-
JBEAP-13299 [GSS](7.0.z) JBJCA-1355 - set-tx-query-timeout does not work when the remaining transaction timeout is shorter than one second
- Closed