db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1337258 - in /db/derby/code/branches/10.8: ./ java/client/org/apache/derby/client/net/ java/engine/org/apache/derby/impl/store/raw/data/ java/testing/org/apache/derbyTesting/functionTests/tests/store/
Date Fri, 11 May 2012 16:23:16 GMT
Author: rhillegas
Date: Fri May 11 16:23:16 2012
New Revision: 1337258

URL: http://svn.apache.org/viewvc?rev=1337258&view=rev
Log:
DERBY-5234: Port 1335570 and 1335677 from trunk to 10.8 branch.

Added:
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/store/Derby5234Test.java
      - copied, changed from r1335570, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/Derby5234Test.java
Modified:
    db/derby/code/branches/10.8/   (props changed)
    db/derby/code/branches/10.8/java/client/org/apache/derby/client/net/NetCursor.java   (props
changed)
    db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/store/raw/data/AllocExtent.java
    db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/store/raw/data/AllocPage.java
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java

Propchange: db/derby/code/branches/10.8/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk:r1335570,1335677

Propchange: db/derby/code/branches/10.8/java/client/org/apache/derby/client/net/NetCursor.java
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk/java/client/org/apache/derby/client/net/NetCursor.java:r1335570,1335677

Modified: db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/store/raw/data/AllocExtent.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/store/raw/data/AllocExtent.java?rev=1337258&r1=1337257&r2=1337258&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/store/raw/data/AllocExtent.java
(original)
+++ db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/store/raw/data/AllocExtent.java
Fri May 11 16:23:16 2012
@@ -207,7 +207,6 @@ public class AllocExtent implements Exte
 							"length " + length + " > maxlength " + maxlength);
 		}
 
-
 		this.extentOffset = offset;
 		this.extentStart = start;
 		this.extentEnd = start+maxlength-1;
@@ -575,7 +574,7 @@ public class AllocExtent implements Exte
             }
         }
 
-        if (new_highest_page >= 0)
+        if (new_highest_page + 1 >= 0)
         {
             freePages.shrink(new_highest_page + 1);
             unFilledPages.shrink(new_highest_page + 1);

Modified: db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/store/raw/data/AllocPage.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/store/raw/data/AllocPage.java?rev=1337258&r1=1337257&r2=1337258&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/store/raw/data/AllocPage.java
(original)
+++ db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/store/raw/data/AllocPage.java
Fri May 11 16:23:16 2012
@@ -1069,15 +1069,15 @@ public class AllocPage extends StoredPag
 			SanityManager.ASSERT(isLatched(), "page is not latched");
         }
 
-        int last_valid_page = extent.compress(owner, ntt, this);
+        int last_valid_page_bit = extent.compress(owner, ntt, this);
 
-        if (last_valid_page >= 0)
+        if (last_valid_page_bit >= 0)
         {
             // a non-negative return means that pages can be returned to
             // the operating system.
-            myContainer.truncatePages(extent.getPagenum(last_valid_page));
+            myContainer.truncatePages(extent.getPagenum(last_valid_page_bit));
 
-            if (last_valid_page == this.getPageNumber())
+            if (last_valid_page_bit == 0)
             {
                 // all pages of the extent have been returned to OS.
                 all_pages_compressed = true;

Copied: db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/store/Derby5234Test.java
(from r1335570, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/Derby5234Test.java)
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/store/Derby5234Test.java?p2=db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/store/Derby5234Test.java&p1=db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/Derby5234Test.java&r1=1335570&r2=1337258&rev=1337258&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/Derby5234Test.java
(original)
+++ db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/store/Derby5234Test.java
Fri May 11 16:23:16 2012
@@ -43,6 +43,9 @@ public class Derby5234Test extends BaseJ
     // this number of rows will force Derby to grab a second allocation page for the table
     private static  final   long    ITERATIONS = 12500;
 
+    // highest row count which does NOT trip the bug
+    private static  final   long    MAX_KEY_PER_FIRST_EXTENT = 10217L;
+
     private static  final   int     VARCHAR_LENGTH = 2000;
     private static  final   String  SEED = "0123456789";
 
@@ -75,6 +78,28 @@ public class Derby5234Test extends BaseJ
         return TestConfiguration.defaultSuite( Derby5234Test.class );
     }
 
+    // do this for each test case
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        
+        goodStatement
+            (
+             getConnection(),
+             "create table t5234( a bigint, b varchar( " + VARCHAR_LENGTH + " ) )"
+             );
+    }
+    protected void tearDown() throws Exception
+    {
+        goodStatement
+            (
+             getConnection(),
+             "drop table t5234"
+             );
+        
+        super.tearDown();
+    }
+    
     ///////////////////////////////////////////////////////////////////////////////////
     //
     // TESTS
@@ -89,30 +114,28 @@ public class Derby5234Test extends BaseJ
      */
     public void test_01_basic() throws Exception
     {
+        vetBasic( ITERATIONS );
+    }
+    private void vetBasic( long rowCount ) throws Exception
+    {
         Connection  conn = getConnection();
 
-        goodStatement
-            (
-             conn,
-             "create table t5234( a bigint, b varchar( " + VARCHAR_LENGTH + " ) )"
-             );
-
         // this makes the test run faster
         boolean oldAutoCommit = conn.getAutoCommit();
         conn.setAutoCommit( false );
 
-        insertRows( conn );
+        insertRows( conn, rowCount );
         deleteRows( conn );
         compressTable( conn );
 
         // the bug would cause the second round of insertions to write
         // beyond the end of the file
-        insertRows( conn );
+        insertRows( conn, rowCount );
         
         conn.setAutoCommit( oldAutoCommit );
     }
     /** Fill the table with enough rows to force Derby to grab a second allocation page */
-    private void    insertRows( Connection conn )
+    private void    insertRows( Connection conn, long iterations )
         throws Exception
     {
         PreparedStatement insert = chattyPrepare
@@ -123,9 +146,9 @@ public class Derby5234Test extends BaseJ
         String          varcharValue = makeVarcharValue();
 
         long    percent = 0L;
-        for ( long i = 0; i < ITERATIONS; i++)
+        for ( long i = 0; i < iterations; i++)
         {
-            if ( (i * 10) / ITERATIONS  > percent)
+            if ( (i * 10) / iterations  > percent)
             {
                 conn.commit();
                 percent++;
@@ -170,6 +193,26 @@ public class Derby5234Test extends BaseJ
         conn.commit();
     }
 
+    /**
+     * <p>
+     * Test with the highest row count which did NOT trip the bug.
+     * </p>
+     */
+    public void test_02_maxOK() throws Exception
+    {
+        vetBasic( MAX_KEY_PER_FIRST_EXTENT );
+    }
+    
+    /**
+     * <p>
+     * Test with one more than the highest good value.
+     * </p>
+     */
+    public void test_03_triggeringEdge() throws Exception
+    {
+        vetBasic( MAX_KEY_PER_FIRST_EXTENT + 1L );
+    }
+    
     ///////////////////////////////////////////////////////////////////////////////////
     //
     // HELPER METHODS

Modified: db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java?rev=1337258&r1=1337257&r2=1337258&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java
(original)
+++ db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java
Fri May 11 16:23:16 2012
@@ -72,6 +72,7 @@ public class _Suite extends BaseTestCase
         suite.addTest(AccessTest.suite());
         suite.addTest(AutomaticIndexStatisticsTest.suite());
         suite.addTest(Derby5582AutomaticIndexStatisticsTest.suite());
+        suite.addTest(Derby5234Test.suite());
         suite.addTest(AutomaticIndexStatisticsMultiTest.suite());
         suite.addTest(BTreeMaxScanTest.suite());
         suite.addTest(MadhareTest.suite());



Mime
View raw message