Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 20593 invoked from network); 20 Aug 2009 12:17:10 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 20 Aug 2009 12:17:10 -0000 Received: (qmail 9269 invoked by uid 500); 20 Aug 2009 12:17:29 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 9240 invoked by uid 500); 20 Aug 2009 12:17:29 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 9231 invoked by uid 99); 20 Aug 2009 12:17:29 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Aug 2009 12:17:29 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Aug 2009 12:17:26 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 925A7238888E; Thu, 20 Aug 2009 12:17:05 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r806139 - in /db/derby/code/branches/10.4: ./ java/engine/org/apache/derby/impl/store/access/btree/BTreeController.java java/testing/org/apache/derbyTesting/functionTests/tests/lang/NullableUniqueConstraintTest.java Date: Thu, 20 Aug 2009 12:17:04 -0000 To: derby-commits@db.apache.org From: kahatlen@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090820121705.925A7238888E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kahatlen Date: Thu Aug 20 12:17:03 2009 New Revision: 806139 URL: http://svn.apache.org/viewvc?rev=806139&view=rev Log: DERBY-4081: BTreeController.comparePreviousRecord() may fail to release latch on left-most leaf Merged fix from trunk (revision 805696). Modified: db/derby/code/branches/10.4/ (props changed) db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/access/btree/BTreeController.java db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/lang/NullableUniqueConstraintTest.java Propchange: db/derby/code/branches/10.4/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Thu Aug 20 12:17:03 2009 @@ -1 +1 @@ -/db/derby/code/trunk:788436 +/db/derby/code/trunk:788436,805696 Modified: db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/access/btree/BTreeController.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/access/btree/BTreeController.java?rev=806139&r1=806138&r2=806139&view=diff ============================================================================== --- db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/access/btree/BTreeController.java (original) +++ db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/access/btree/BTreeController.java Thu Aug 20 12:17:03 2009 @@ -384,14 +384,15 @@ //slot is pointing before the first slot //get left sibiling leaf = (LeafControlRow) leaf.getLeftSibling(this); + if (newLeaf) { + oldLeaf.release(); + } + newLeaf = true; //no left sibiling if (leaf == null) return NO_MATCH; //set the slot to last slot number slot = leaf.page.recordCount() - 1; - if (newLeaf) - oldLeaf.release(); - newLeaf = true; // DERBY-4027: We have moved to the previous page and need // to recheck that the slot number is valid (it won't be // if the page we moved to is empty). Restart from the top Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/lang/NullableUniqueConstraintTest.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/lang/NullableUniqueConstraintTest.java?rev=806139&r1=806138&r2=806139&view=diff ============================================================================== --- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/lang/NullableUniqueConstraintTest.java (original) +++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/lang/NullableUniqueConstraintTest.java Thu Aug 20 12:17:03 2009 @@ -531,6 +531,33 @@ "update constraintest set val1 = '2' where val1 = '3'"); } + /** + * Test that we can insert and delete the same value multiple times in a + * nullable unique index. This used to cause a livelock before DERBY-4081 + * because the duplicate check on insert sometimes didn't release all + * latches. + */ + public void testInsertDeleteContinuouslySameValue() throws SQLException { + // Must disable auto-commit for reliable reproduction, otherwise the + // post-commit worker thread will remove deleted index rows. + setAutoCommit(false); + + Statement s = createStatement(); + s.execute("create table d4081(x int unique)"); + + // The loop below did not get past the 372nd iteration before + // DERBY-4081 was fixed. Try 500 iterations now. + PreparedStatement ins = prepareStatement("insert into d4081 values 0"); + PreparedStatement del = prepareStatement("delete from d4081"); + for (int i = 0; i < 500; i++) { + ins.execute(); + del.execute(); + } + + // Verify that the table is empty after the last delete operation. + assertTableRowCount("D4081", 0); + } + public static void main(String [] args) { TestResult tr = new TestResult(); Test t = suite();