[jboss-jira] [JBoss JIRA] (JBJCA-1355) set-tx-query-timeout does not work when the remaining transaction timeout is shorter than one second

RH Bugzilla Integration (JIRA) issues at jboss.org
Mon Apr 16 12:23:00 EDT 2018


    [ https://issues.jboss.org/browse/JBJCA-1355?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13561903#comment-13561903 ] 

RH Bugzilla Integration commented on JBJCA-1355:
------------------------------------------------

Jan Kurik <jkurik at redhat.com> changed the Status of [bug 1497591|https://bugzilla.redhat.com/show_bug.cgi?id=1497591] from VERIFIED to CLOSED

> set-tx-query-timeout does not work when the remaining transaction timeout is shorter than one second
> ----------------------------------------------------------------------------------------------------
>
>                 Key: JBJCA-1355
>                 URL: https://issues.jboss.org/browse/JBJCA-1355
>             Project: IronJacamar
>          Issue Type: Bug
>          Components: JDBC
>            Reporter: Masafumi Miura
>            Assignee: Stefano Maestri
>
> {{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
> {code}
> 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    }
> {code}
> - https://github.com/ironjacamar/ironjacamar/blob/ironjacamar-1.3.7.Final/adapters/src/main/java/org/jboss/jca/adapters/jdbc/WrapperDataSource.java#L190-L218
> {code}
> 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    }
> {code}



--
This message was sent by Atlassian JIRA
(v7.5.0#75005)


More information about the jboss-jira mailing list