You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2009/04/21 15:38:42 UTC

svn commit: r767143 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/store/access/btree/BTreeController.java testing/org/apache/derbyTesting/functionTests/tests/lang/NullableUniqueConstraintTest.java

Author: kahatlen
Date: Tue Apr 21 13:38:42 2009
New Revision: 767143

URL: http://svn.apache.org/viewvc?rev=767143&view=rev
Log:
DERBY-4097: WaitError in NullableUniqueConstraintTest.testMixedInsertDelete

If we have to wait for a latch when walking the B-tree backwards,
release all latches and rescan from the root of the tree instead of
failing with a WaitError.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeController.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/NullableUniqueConstraintTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeController.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeController.java?rev=767143&r1=767142&r2=767143&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeController.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeController.java Tue Apr 21 13:38:42 2009
@@ -381,8 +381,8 @@
         LeafControlRow originalLeaf = leaf;
         while (leaf != null) {
             if (slot == 0) {
+                LeafControlRow oldLeaf = leaf;
                 try {
-                    LeafControlRow oldLeaf = leaf;
                     //slot is pointing before the first slot
                     //get left sibiling
                     leaf = (LeafControlRow) leaf.getLeftSibling(this);
@@ -400,7 +400,14 @@
                     // of the loop body to get the slot number rechecked.
                     continue;
                 } catch (WaitError we) {
-                    throw StandardException.plainWrapException(we);
+                    // DERBY-4097: Couldn't latch the left sibling without
+                    // waiting. Release all latches and rescan from top of
+                    // B-tree to prevent deadlock.
+                    if (newLeaf) {
+                        oldLeaf.release();
+                    }
+                    originalLeaf.release();
+                    return RESCAN_REQUIRED;
                 }
             }
             rh = leaf.page.fetchFromSlot(null, slot, rows, null, true);

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/NullableUniqueConstraintTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/NullableUniqueConstraintTest.java?rev=767143&r1=767142&r2=767143&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/NullableUniqueConstraintTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/NullableUniqueConstraintTest.java Tue Apr 21 13:38:42 2009
@@ -473,7 +473,11 @@
         // The error happened most frequently in the second iteration, but
         // it didn't always, so we repeat it ten times to increase the
         // likelihood of triggering the bug.
-        for (int i = 0; i < 10; i++) {
+        // DERBY-4097: Increase the number of iterations to increase the
+        // likelihood of exposing another timing-dependent problem with a
+        // WaitError caused by a conflict between the post-commit thread
+        // and the user thread.
+        for (int i = 0; i < 100; i++) {
             for (int j = 0; j < 1000; j++) {
                 insert.setInt(1, j);
                 insert.addBatch();