db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r672298 - in /db/derby/code/branches/10.3/java: engine/org/apache/derby/impl/store/raw/data/ testing/org/apache/derbyTesting/functionTests/tests/store/
Date Fri, 27 Jun 2008 15:30:11 GMT
Author: mikem
Date: Fri Jun 27 08:30:11 2008
New Revision: 672298

URL: http://svn.apache.org/viewvc?rev=672298&view=rev
Log:
DERBY-3625

backporting fix from trunk to 10.3 branch (change 671605)

Fixed SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE() bug where during the
defragment phase one part of the code would think there was enough room to
move a record, but because the new record id on the destination page would
take more room than on the source page the move actually would not succeed.
In this case an XSDA3 errror would be thrown and the compress would fail.

This would cause intermittent errors in the nightly concateTests.


Added:
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/store/Derby3625Test.java
      - copied unchanged from r671605, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/Derby3625Test.java
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/store/StoreBaseTest.java
      - copied unchanged from r671605, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/StoreBaseTest.java
Modified:
    db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/store/raw/data/StoredPage.java
    db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/store/raw/data/StoredRecordHeader.java
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/store/raw/data/StoredPage.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/store/raw/data/StoredPage.java?rev=672298&r1=672297&r2=672298&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/store/raw/data/StoredPage.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/store/raw/data/StoredPage.java
Fri Jun 27 08:30:11 2008
@@ -1366,8 +1366,29 @@
 		return((freeSpace - bytesNeeded) >= 0);
 	}
 
-	protected boolean spaceForCopy(int spaceNeeded)
+    /**
+     * Does this page have enough space to move the row to it.
+     * <p>
+     * Calculate if a row of length "spaceNeeded" with current record id
+     * "source_id" will fit on this page.
+     *
+     * @param spaceNeeded   length of the row encoded with source_id record id.
+     * @param source_id     record id of the row being moved. 
+     *
+	 * @return true if the record will fit on this page, after being given a
+     *         new record id as the next id on this page.
+     *
+     * @exception  StandardException  Standard exception policy.
+     **/
+	protected boolean spaceForCopy(
+    int spaceNeeded, 
+    int source_id)
 	{
+        spaceNeeded = 
+            spaceNeeded 
+            - StoredRecordHeader.getStoredSizeRecordId(source_id) 
+            + StoredRecordHeader.getStoredSizeRecordId(nextId);
+
         // add up the space needed by the rows, add in minimumRecordSize
         // if length of actual row is less than minimumRecordSize.
         int bytesNeeded = slotEntrySize + 
@@ -6859,6 +6880,7 @@
                 false);
 
             int row_size = getRecordPortionLength(slot);
+            int record_id = getHeaderAtSlot(slot).getId();
 
             // first see if row will fit on current page being used to insert
             StoredPage dest_page = 
@@ -6867,7 +6889,7 @@
             if (dest_page != null)
             {
                 if ((dest_page.getPageNumber() >= getPageNumber()) ||
-                    (!dest_page.spaceForCopy(row_size)))
+                    (!dest_page.spaceForCopy(row_size, record_id)))
                 {
                     // page won't work
                     dest_page.unlatch();
@@ -6885,7 +6907,7 @@
                 if (dest_page != null)
                 {
                     if ((dest_page.getPageNumber() >= getPageNumber()) ||
-                        (!dest_page.spaceForCopy(row_size)))
+                        (!dest_page.spaceForCopy(row_size, record_id)))
                     {
                         // page won't work
                         dest_page.unlatch();
@@ -7989,8 +8011,6 @@
      * 00000130: 0000 0000 0000 0000 0000 0000 0000 0000  ................
      *
      * <p>
-     * RESOLVE - this has been hacked together and is not efficient.  There
-     * are probably some java utilities to use.
      *
 	 * @return The string with the hex dump in it.
      *
@@ -8001,26 +8021,31 @@
 		return org.apache.derby.iapi.util.StringUtil.hexDump(data);
     }
 
-	private String pageHeaderToString()
-	{
-		if (SanityManager.DEBUG) {
-			return "page id " + getIdentity() + 
-				" Overflow: " + isOverflowPage +
-				" PageVersion: " + getPageVersion() +
-				" SlotsInUse: " + slotsInUse +
-				" DeletedRowCount: " + deletedRowCount +
-				" PageStatus: " + getPageStatus() + 
-				" NextId: " + nextId + 
-				" firstFreeByte: " + firstFreeByte + 
-				" freeSpace: " + freeSpace + 
-				" totalSpace: " + totalSpace + 
-				" spareSpace: " + spareSpace + 
-                " PageSize: " + getPageSize() +
+    private String pageHeaderToString()
+    {
+        if (SanityManager.DEBUG) 
+        {
+            return 
+                "page id: "             + getIdentity()     + 
+                " Overflow: "           + isOverflowPage    +
+                " PageVersion: "        + getPageVersion()  +
+                " SlotsInUse: "         + slotsInUse        +
+                " DeletedRowCount: "    + deletedRowCount   +
+                " PageStatus: "         + getPageStatus()   + 
+                " NextId: "             + nextId            + 
+                " firstFreeByte: "      + firstFreeByte     + 
+                " freeSpace: "          + freeSpace         + 
+                " totalSpace: "         + totalSpace        + 
+                " spareSpace: "         + spareSpace        + "%" + 
+                " minimumRecordSize : " + minimumRecordSize +
+                " PageSize: "           + getPageSize()     +
                 "\n";
-		}
-		else
-			return null;
-	}
+        }
+        else
+        {
+            return null;
+        }
+    }
 
 	private String recordToString(int slot)
 	{

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/store/raw/data/StoredRecordHeader.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/store/raw/data/StoredRecordHeader.java?rev=672298&r1=672297&r2=672298&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/store/raw/data/StoredRecordHeader.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/store/raw/data/StoredRecordHeader.java
Fri Jun 27 08:30:11 2008
@@ -759,6 +759,19 @@
         return;
 	}
 
+    /**
+     * Return length on disk of the record id portion of the record header
+     *
+     * Record id is part of the record header and is stored in an internal
+     * compressed format.  The length of this format depends on the value
+     * of the record id.
+     *
+     * @return length of encoded record id on disk.
+     **/
+    public static final int getStoredSizeRecordId(int record_id)
+    {
+        return(CompressedNumber.sizeInt(record_id));
+    }
 
 	public String toString()
 	{

Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java?rev=672298&r1=672297&r2=672298&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java
(original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java
Fri Jun 27 08:30:11 2008
@@ -53,6 +53,7 @@
         
         suite.addTest(BootAllTest.suite());
 
+        suite.addTest(Derby3625Test.suite());
         // Encryption only supported for Derby in J2SE/J2EE environments.
         // J2ME (JSR169) does not support encryption.
         if (JDBC.vmSupportsJDBC3()) {



Mime
View raw message