Derby
  1. Derby
  2. DERBY-5278

AssertionFailedError in IndexSplitDeadlockTest.testBTreeForwardScan_fetchRows_resumeAfterWait_unique_split()

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 10.8.1.2, 10.9.1.0
    • Fix Version/s: 10.8.2.2, 10.9.1.0
    • Component/s: Test
    • Labels:
      None
    • Environment:
      java version "1.4.2_30"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_30-b04)
      Java HotSpot(TM) Client VM (build 1.4.2_30-b04, mixed mode)

      Red Hat Enterprise Linux Server release 5.1 (Tikanga)
    • Bug behavior facts:
      Regression Test Failure

      Description

      This failure has been seen occasionally (three times so far) on Java 1.4.2_30 on Linux. Examples:

      http://dbtg.foundry.sun.com/derby/test/Daily/jvm1.4/testing/testlog/lin/1095760-suitesAll_diff.txt
      http://dbtg.foundry.sun.com/derby/test/Daily/jvm1.4/testing/testlog/lin/1102361-suitesAll_diff.txt
      http://dbtg.foundry.sun.com/derby/test/Daily/jvm1.4/testing/testlog/lin/1133954-suitesAll_diff.txt

      1) testBTreeForwardScan_fetchRows_resumeAfterWait_unique_split(org.apache.derbyTesting.functionTests.tests.store.IndexSplitDeadlockTest)junit.framework.AssertionFailedError: expected:<0> but was:<-299>
      at org.apache.derbyTesting.functionTests.tests.store.IndexSplitDeadlockTest.testBTreeForwardScan_fetchRows_resumeAfterWait_unique_split(IndexSplitDeadlockTest.java:397)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:112)
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
      at junit.extensions.TestSetup.run(TestSetup.java:25)
      at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
      at junit.extensions.TestSetup.run(TestSetup.java:25)
      at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)

      1. sync.diff
        3 kB
        Knut Anders Hatlen

        Issue Links

          Activity

          Hide
          Knut Anders Hatlen added a comment -

          The test case that fails runs in two threads that need to do the operations in a specific order. Currently, the threads use Thread.sleep() to ensure the ordering. This may break if the timing isn't quite what we expect.

          It looks like the assert failure happens because the helper thread has started inserting new rows into the table too early. It should wait until the main thread has started an index scan and got blocked on a lock that the helper thread is holding.

          The attached patch (sync.diff) makes the threads synchronize using an object on which they call wait/notify to tell the other thread that they're in the expected state. This should be more reliable than Thread.sleep(), and it should also make the test run slightly faster in the common case, since the sleep time is probably higher than needed on most machines.

          Now the helper thread will know that the main thread is ready to start the index scan before it goes ahead inserting more rows. And the main thread knows that the helper thread has obtained the required lock before it starts the index scan. There's still one sleep() call in the test case to ensure that the index scan has actually started before the helper thread begins inserting, but since both threads are in a well-known state when sleep() is called, it should be much more likely to work as intended.

          Show
          Knut Anders Hatlen added a comment - The test case that fails runs in two threads that need to do the operations in a specific order. Currently, the threads use Thread.sleep() to ensure the ordering. This may break if the timing isn't quite what we expect. It looks like the assert failure happens because the helper thread has started inserting new rows into the table too early. It should wait until the main thread has started an index scan and got blocked on a lock that the helper thread is holding. The attached patch (sync.diff) makes the threads synchronize using an object on which they call wait/notify to tell the other thread that they're in the expected state. This should be more reliable than Thread.sleep(), and it should also make the test run slightly faster in the common case, since the sleep time is probably higher than needed on most machines. Now the helper thread will know that the main thread is ready to start the index scan before it goes ahead inserting more rows. And the main thread knows that the helper thread has obtained the required lock before it starts the index scan. There's still one sleep() call in the test case to ensure that the index scan has actually started before the helper thread begins inserting, but since both threads are in a well-known state when sleep() is called, it should be much more likely to work as intended.
          Hide
          Knut Anders Hatlen added a comment -

          Committed revision 1136844.

          Show
          Knut Anders Hatlen added a comment - Committed revision 1136844.
          Hide
          Knut Anders Hatlen added a comment -

          Merged to 10.8. Committed revision 1138003.

          Show
          Knut Anders Hatlen added a comment - Merged to 10.8. Committed revision 1138003.

            People

            • Assignee:
              Knut Anders Hatlen
              Reporter:
              Knut Anders Hatlen
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development