OpenJPA
  1. OpenJPA
  2. OPENJPA-1565

QueryTimeOut and LockTimeOut exceptions are not raised correctly

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0-M1, 2.0.0-M2, 2.0.0-M3, 2.0.0-beta, 2.0.0-beta2
    • Fix Version/s: 2.0.0-beta3
    • Component/s: jdbc, jpa, kernel, query, sql
    • Labels:
      None

      Description

      Narrowing SQL Exception to a more specific exception such as lock or query or referential integrity violation does not distinguish correctly whether a query or lock request has timed out.
      This distinction is critical for JPA 2.0 spec compliance because QueryTimeOut and LockTimeOut exceptions are not supposed to cause rollback as per the spe (Section 3.9).

        Issue Links

          Activity

          Hide
          Donald Woods added a comment - - edited

          Looks like this is causing new junit test failures on any DB besides Derby.

          MySQL 2 tests -
          1) TestTimeoutException.testQueryTimeOutExceptionWhileQueryingWithLocksOnAlreadyLockedEntities (org.apache.openjpa.persistence.query)
          junit.framework.AssertionFailedError: junit.framework.AssertionFailedError was raised but expected javax.persistence.QueryTimeoutException
          at org.apache.openjpa.persistence.query.TestTimeoutException.assertError(TestTimeoutException.java:141)
          at org.apache.openjpa.persistence.query.TestTimeoutException.testQueryTimeOutExceptionWhileQueryingWithLocksOnAlreadyLockedEntities(TestTimeoutException.java:63)
          2) TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities (org.apache.openjpa.persistence.query)
          junit.framework.AssertionFailedError: junit.framework.AssertionFailedError was raised but expected javax.persistence.LockTimeoutException
          at org.apache.openjpa.persistence.query.TestTimeoutException.assertError(TestTimeoutException.java:141)
          at org.apache.openjpa.persistence.query.TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities(TestTimeoutException.java:93)

          Microsoft SQL 2008 - 1 test -
          TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities (org.apache.openjpa.persistence.query)
          junit.framework.AssertionFailedError: junit.framework.AssertionFailedError was raised but expected javax.persistence.LockTimeoutException
          at org.apache.openjpa.persistence.query.TestTimeoutException.assertError(TestTimeoutException.java:141)
          at org.apache.openjpa.persistence.query.TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities(TestTimeoutException.java:93)

          DB2 - 2 tests -
          1) TestTimeoutException.testQueryTimeOutExceptionWhileQueryingWithLocksOnAlreadyLockedEntities (org.apache.openjpa.persistence.query)
          junit.framework.AssertionFailedError: junit.framework.AssertionFailedError was raised but expected javax.persistence.QueryTimeoutException
          at org.apache.openjpa.persistence.query.TestTimeoutException.assertError(TestTimeoutException.java:141)
          at org.apache.openjpa.persistence.query.TestTimeoutException.testQueryTimeOutExceptionWhileQueryingWithLocksOnAlreadyLockedEntities(TestTimeoutException.java:63)
          2) TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities (org.apache.openjpa.persistence.query)
          junit.framework.AssertionFailedError: junit.framework.AssertionFailedError was raised but expected javax.persistence.LockTimeoutException
          at org.apache.openjpa.persistence.query.TestTimeoutException.assertError(TestTimeoutException.java:141)
          at org.apache.openjpa.persistence.query.TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities(TestTimeoutException.java:93)

          Show
          Donald Woods added a comment - - edited Looks like this is causing new junit test failures on any DB besides Derby. MySQL 2 tests - 1) TestTimeoutException.testQueryTimeOutExceptionWhileQueryingWithLocksOnAlreadyLockedEntities (org.apache.openjpa.persistence.query) junit.framework.AssertionFailedError: junit.framework.AssertionFailedError was raised but expected javax.persistence.QueryTimeoutException at org.apache.openjpa.persistence.query.TestTimeoutException.assertError(TestTimeoutException.java:141) at org.apache.openjpa.persistence.query.TestTimeoutException.testQueryTimeOutExceptionWhileQueryingWithLocksOnAlreadyLockedEntities(TestTimeoutException.java:63) 2) TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities (org.apache.openjpa.persistence.query) junit.framework.AssertionFailedError: junit.framework.AssertionFailedError was raised but expected javax.persistence.LockTimeoutException at org.apache.openjpa.persistence.query.TestTimeoutException.assertError(TestTimeoutException.java:141) at org.apache.openjpa.persistence.query.TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities(TestTimeoutException.java:93) Microsoft SQL 2008 - 1 test - TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities (org.apache.openjpa.persistence.query) junit.framework.AssertionFailedError: junit.framework.AssertionFailedError was raised but expected javax.persistence.LockTimeoutException at org.apache.openjpa.persistence.query.TestTimeoutException.assertError(TestTimeoutException.java:141) at org.apache.openjpa.persistence.query.TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities(TestTimeoutException.java:93) DB2 - 2 tests - 1) TestTimeoutException.testQueryTimeOutExceptionWhileQueryingWithLocksOnAlreadyLockedEntities (org.apache.openjpa.persistence.query) junit.framework.AssertionFailedError: junit.framework.AssertionFailedError was raised but expected javax.persistence.QueryTimeoutException at org.apache.openjpa.persistence.query.TestTimeoutException.assertError(TestTimeoutException.java:141) at org.apache.openjpa.persistence.query.TestTimeoutException.testQueryTimeOutExceptionWhileQueryingWithLocksOnAlreadyLockedEntities(TestTimeoutException.java:63) 2) TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities (org.apache.openjpa.persistence.query) junit.framework.AssertionFailedError: junit.framework.AssertionFailedError was raised but expected javax.persistence.LockTimeoutException at org.apache.openjpa.persistence.query.TestTimeoutException.assertError(TestTimeoutException.java:141) at org.apache.openjpa.persistence.query.TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities(TestTimeoutException.java:93)
          Hide
          Pinaki Poddar added a comment -

          1. Note the SQL Error State and Code of the SQL Exception when it fails to throw expected exception
          2. Check sql-error-state-codes.xml for that database dictionary. The error states are categorized in that file. If the observed error does not occur in the list of error states, add it (the error state not the error code).
          3. Also check corresponding DB dictionary implementation isFatalException() and ensure that it returns false when query/lock timeouts are intended to be raised.
          4. Returning false from isFatalException() will ensure that at facade level the transaction is not rolled back.

          Show
          Pinaki Poddar added a comment - 1. Note the SQL Error State and Code of the SQL Exception when it fails to throw expected exception 2. Check sql-error-state-codes.xml for that database dictionary. The error states are categorized in that file. If the observed error does not occur in the list of error states, add it (the error state not the error code). 3. Also check corresponding DB dictionary implementation isFatalException() and ensure that it returns false when query/lock timeouts are intended to be raised. 4. Returning false from isFatalException() will ensure that at facade level the transaction is not rolled back.
          Hide
          Pinaki Poddar added a comment -

          I ran with mysql-connector-java-5.1.6 locally and the tests passed for
          MySQL.

          I had given Jody a patch for DB2 errors – will check if he can verify

          Can you please send me the stacktrace of SQL error for MS-SQL 2008?

          Regards –

          Pinaki

          "Donald Woods (JIRA)" <jira@apache.org>
          03/16/2010 11:36 AM

          To
          Pinaki Poddar/Dallas/IBM@IBMUS
          cc

          Subject
          [jira] Issue Comment Edited: (OPENJPA-1565) QueryTimeOut and LockTimeOut
          exceptions are not raised correctly

          [
          https://issues.apache.org/jira/browse/OPENJPA-1565?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12845979#action_12845979
          ]

          Donald Woods edited comment on OPENJPA-1565 at 3/16/10 4:35 PM:
          ----------------------------------------------------------------

          Looks like this is causing new junit test failures on any DB besides
          Derby.

          MySQL 2 tests -
          1)
          TestTimeoutException.testQueryTimeOutExceptionWhileQueryingWithLocksOnAlreadyLockedEntities
          (org.apache.openjpa.persistence.query)
          junit.framework.AssertionFailedError: junit.framework.AssertionFailedError
          was raised but expected javax.persistence.QueryTimeoutException
          at
          org.apache.openjpa.persistence.query.TestTimeoutException.assertError(TestTimeoutException.java:141)
          at
          org.apache.openjpa.persistence.query.TestTimeoutException.testQueryTimeOutExceptionWhileQueryingWithLocksOnAlreadyLockedEntities(TestTimeoutException.java:63)
          2)
          TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities
          (org.apache.openjpa.persistence.query)
          junit.framework.AssertionFailedError: junit.framework.AssertionFailedError
          was raised but expected javax.persistence.LockTimeoutException
          at
          org.apache.openjpa.persistence.query.TestTimeoutException.assertError(TestTimeoutException.java:141)
          at
          org.apache.openjpa.persistence.query.TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities(TestTimeoutException.java:93)

          Microsoft SQL 2008 - 1 test -
          TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities
          (org.apache.openjpa.persistence.query)
          junit.framework.AssertionFailedError: junit.framework.AssertionFailedError
          was raised but expected javax.persistence.LockTimeoutException
          at
          org.apache.openjpa.persistence.query.TestTimeoutException.assertError(TestTimeoutException.java:141)
          at
          org.apache.openjpa.persistence.query.TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities(TestTimeoutException.java:93)

          DB2 - 2 tests -
          1)
          TestTimeoutException.testQueryTimeOutExceptionWhileQueryingWithLocksOnAlreadyLockedEntities
          (org.apache.openjpa.persistence.query)
          junit.framework.AssertionFailedError: junit.framework.AssertionFailedError
          was raised but expected javax.persistence.QueryTimeoutException
          at
          org.apache.openjpa.persistence.query.TestTimeoutException.assertError(TestTimeoutException.java:141)
          at
          org.apache.openjpa.persistence.query.TestTimeoutException.testQueryTimeOutExceptionWhileQueryingWithLocksOnAlreadyLockedEntities(TestTimeoutException.java:63)
          2)
          TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities
          (org.apache.openjpa.persistence.query)
          junit.framework.AssertionFailedError: junit.framework.AssertionFailedError
          was raised but expected javax.persistence.LockTimeoutException
          at
          org.apache.openjpa.persistence.query.TestTimeoutException.assertError(TestTimeoutException.java:141)
          at
          org.apache.openjpa.persistence.query.TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities(TestTimeoutException.java:93)

          was (Author: drwoods):
          Looks like this is causing new junit test failures on any DB besides
          Derby.

          MySQL 2 tests -
          1)
          TestTimeoutException.testQueryTimeOutExceptionWhileQueryingWithLocksOnAlreadyLockedEntities
          (org.apache.openjpa.persistence.query)
          junit.framework.AssertionFailedError: junit.framework.AssertionFailedError
          was raised but expected javax.persistence.QueryTimeoutException
          at
          org.apache.openjpa.persistence.query.TestTimeoutException.assertError(TestTimeoutException.java:141)
          at
          org.apache.openjpa.persistence.query.TestTimeoutException.testQueryTimeOutExceptionWhileQueryingWithLocksOnAlreadyLockedEntities(TestTimeoutException.java:63)
          2)
          TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities
          (org.apache.openjpa.persistence.query)
          junit.framework.AssertionFailedError: junit.framework.AssertionFailedError
          was raised but expected javax.persistence.LockTimeoutException
          at
          org.apache.openjpa.persistence.query.TestTimeoutException.assertError(TestTimeoutException.java:141)
          at
          org.apache.openjpa.persistence.query.TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities(TestTimeoutException.java:93)

          Microsoft SQL 2008 - 1 test -
          TestException.testThrowsEntityExistsException
          (org.apache.openjpa.persistence.exception)
          junit.framework.AssertionFailedError: <openjpa-2.0.0-SNAPSHOT-runknown
          fatal store error> org.apache.openjpa.persistence.RollbackException: The
          transaction has been rolled back. See the nested exceptions for details on
          the errors that occurred. or its cause is not instanceof class
          javax.persistence.EntityExistsException
          at junit.framework.Assert.fail(Assert.java:47)
          at
          org.apache.openjpa.persistence.exception.TestException.assertException(TestException.java:207)

          DB2 - 2 tests -
          1)
          TestTimeoutException.testQueryTimeOutExceptionWhileQueryingWithLocksOnAlreadyLockedEntities
          (org.apache.openjpa.persistence.query)
          junit.framework.AssertionFailedError: junit.framework.AssertionFailedError
          was raised but expected javax.persistence.QueryTimeoutException
          at
          org.apache.openjpa.persistence.query.TestTimeoutException.assertError(TestTimeoutException.java:141)
          at
          org.apache.openjpa.persistence.query.TestTimeoutException.testQueryTimeOutExceptionWhileQueryingWithLocksOnAlreadyLockedEntities(TestTimeoutException.java:63)
          2)
          TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities
          (org.apache.openjpa.persistence.query)
          junit.framework.AssertionFailedError: junit.framework.AssertionFailedError
          was raised but expected javax.persistence.LockTimeoutException
          at
          org.apache.openjpa.persistence.query.TestTimeoutException.assertError(TestTimeoutException.java:141)
          at
          org.apache.openjpa.persistence.query.TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities(TestTimeoutException.java:93)

          2.0.0-beta2
          query or referential integrity violation does not distinguish correctly
          whether a query or lock request has timed out.
          QueryTimeOut and LockTimeOut exceptions are not supposed to cause rollback
          as per the spe (Section 3.9).


          This message is automatically generated by JIRA.
          -
          You can reply to this email to add a comment to the issue online.

          Show
          Pinaki Poddar added a comment - I ran with mysql-connector-java-5.1.6 locally and the tests passed for MySQL. I had given Jody a patch for DB2 errors – will check if he can verify Can you please send me the stacktrace of SQL error for MS-SQL 2008? Regards – Pinaki "Donald Woods (JIRA)" <jira@apache.org> 03/16/2010 11:36 AM To Pinaki Poddar/Dallas/IBM@IBMUS cc Subject [jira] Issue Comment Edited: ( OPENJPA-1565 ) QueryTimeOut and LockTimeOut exceptions are not raised correctly [ https://issues.apache.org/jira/browse/OPENJPA-1565?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12845979#action_12845979 ] Donald Woods edited comment on OPENJPA-1565 at 3/16/10 4:35 PM: ---------------------------------------------------------------- Looks like this is causing new junit test failures on any DB besides Derby. MySQL 2 tests - 1) TestTimeoutException.testQueryTimeOutExceptionWhileQueryingWithLocksOnAlreadyLockedEntities (org.apache.openjpa.persistence.query) junit.framework.AssertionFailedError: junit.framework.AssertionFailedError was raised but expected javax.persistence.QueryTimeoutException at org.apache.openjpa.persistence.query.TestTimeoutException.assertError(TestTimeoutException.java:141) at org.apache.openjpa.persistence.query.TestTimeoutException.testQueryTimeOutExceptionWhileQueryingWithLocksOnAlreadyLockedEntities(TestTimeoutException.java:63) 2) TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities (org.apache.openjpa.persistence.query) junit.framework.AssertionFailedError: junit.framework.AssertionFailedError was raised but expected javax.persistence.LockTimeoutException at org.apache.openjpa.persistence.query.TestTimeoutException.assertError(TestTimeoutException.java:141) at org.apache.openjpa.persistence.query.TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities(TestTimeoutException.java:93) Microsoft SQL 2008 - 1 test - TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities (org.apache.openjpa.persistence.query) junit.framework.AssertionFailedError: junit.framework.AssertionFailedError was raised but expected javax.persistence.LockTimeoutException at org.apache.openjpa.persistence.query.TestTimeoutException.assertError(TestTimeoutException.java:141) at org.apache.openjpa.persistence.query.TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities(TestTimeoutException.java:93) DB2 - 2 tests - 1) TestTimeoutException.testQueryTimeOutExceptionWhileQueryingWithLocksOnAlreadyLockedEntities (org.apache.openjpa.persistence.query) junit.framework.AssertionFailedError: junit.framework.AssertionFailedError was raised but expected javax.persistence.QueryTimeoutException at org.apache.openjpa.persistence.query.TestTimeoutException.assertError(TestTimeoutException.java:141) at org.apache.openjpa.persistence.query.TestTimeoutException.testQueryTimeOutExceptionWhileQueryingWithLocksOnAlreadyLockedEntities(TestTimeoutException.java:63) 2) TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities (org.apache.openjpa.persistence.query) junit.framework.AssertionFailedError: junit.framework.AssertionFailedError was raised but expected javax.persistence.LockTimeoutException at org.apache.openjpa.persistence.query.TestTimeoutException.assertError(TestTimeoutException.java:141) at org.apache.openjpa.persistence.query.TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities(TestTimeoutException.java:93) was (Author: drwoods): Looks like this is causing new junit test failures on any DB besides Derby. MySQL 2 tests - 1) TestTimeoutException.testQueryTimeOutExceptionWhileQueryingWithLocksOnAlreadyLockedEntities (org.apache.openjpa.persistence.query) junit.framework.AssertionFailedError: junit.framework.AssertionFailedError was raised but expected javax.persistence.QueryTimeoutException at org.apache.openjpa.persistence.query.TestTimeoutException.assertError(TestTimeoutException.java:141) at org.apache.openjpa.persistence.query.TestTimeoutException.testQueryTimeOutExceptionWhileQueryingWithLocksOnAlreadyLockedEntities(TestTimeoutException.java:63) 2) TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities (org.apache.openjpa.persistence.query) junit.framework.AssertionFailedError: junit.framework.AssertionFailedError was raised but expected javax.persistence.LockTimeoutException at org.apache.openjpa.persistence.query.TestTimeoutException.assertError(TestTimeoutException.java:141) at org.apache.openjpa.persistence.query.TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities(TestTimeoutException.java:93) Microsoft SQL 2008 - 1 test - TestException.testThrowsEntityExistsException (org.apache.openjpa.persistence.exception) junit.framework.AssertionFailedError: <openjpa-2.0.0-SNAPSHOT-runknown fatal store error> org.apache.openjpa.persistence.RollbackException: The transaction has been rolled back. See the nested exceptions for details on the errors that occurred. or its cause is not instanceof class javax.persistence.EntityExistsException at junit.framework.Assert.fail(Assert.java:47) at org.apache.openjpa.persistence.exception.TestException.assertException(TestException.java:207) DB2 - 2 tests - 1) TestTimeoutException.testQueryTimeOutExceptionWhileQueryingWithLocksOnAlreadyLockedEntities (org.apache.openjpa.persistence.query) junit.framework.AssertionFailedError: junit.framework.AssertionFailedError was raised but expected javax.persistence.QueryTimeoutException at org.apache.openjpa.persistence.query.TestTimeoutException.assertError(TestTimeoutException.java:141) at org.apache.openjpa.persistence.query.TestTimeoutException.testQueryTimeOutExceptionWhileQueryingWithLocksOnAlreadyLockedEntities(TestTimeoutException.java:63) 2) TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities (org.apache.openjpa.persistence.query) junit.framework.AssertionFailedError: junit.framework.AssertionFailedError was raised but expected javax.persistence.LockTimeoutException at org.apache.openjpa.persistence.query.TestTimeoutException.assertError(TestTimeoutException.java:141) at org.apache.openjpa.persistence.query.TestTimeoutException.testLockTimeOutExceptionWhileLockingAlreadyLockedEntities(TestTimeoutException.java:93) 2.0.0-beta2 query or referential integrity violation does not distinguish correctly whether a query or lock request has timed out. QueryTimeOut and LockTimeOut exceptions are not supposed to cause rollback as per the spe (Section 3.9). – This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.
          Hide
          Donald Woods added a comment -

          Code committed by Pinaki. Remaining test issues will be handled via OPENJPA-1594.

          Show
          Donald Woods added a comment - Code committed by Pinaki. Remaining test issues will be handled via OPENJPA-1594 .

            People

            • Assignee:
              Pinaki Poddar
              Reporter:
              Pinaki Poddar
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development