db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r644698 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data: AllocPage.java CachedPage.java
Date Fri, 04 Apr 2008 12:49:11 GMT
Author: kahatlen
Date: Fri Apr  4 05:49:09 2008
New Revision: 644698

URL: http://svn.apache.org/viewvc?rev=644698&view=rev
Log:
DERBY-3116: totalSpace not properly initialized in AllocPage

- in AllocPage.createPage(), set borrowedSpace before
  super.createPage() is called so that getMaxFreeSpace() returns the
  correct value when totalSpace is initialized

- in CachedPage.setPageArray(), call usePageBuffer() also when the old
  buffer is reused. This ensures that totalSpace is recalculated when
  a page object is reused.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/AllocPage.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/CachedPage.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/AllocPage.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/AllocPage.java?rev=644698&r1=644697&r2=644698&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/AllocPage.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/AllocPage.java Fri
Apr  4 05:49:09 2008
@@ -274,9 +274,11 @@
 		 throws StandardException
 	{
 
-		super.createPage(newIdentity, args);
+        // We need to set borrowedSpace before we call super.createPage() so
+        // that totalSpace is initialized correctly (DERBY-3116).
+        borrowedSpace = args.containerInfoSize;
 
-		borrowedSpace = args.containerInfoSize;
+		super.createPage(newIdentity, args);
 
 		if (SanityManager.DEBUG)
 		{
@@ -307,12 +309,19 @@
 		reserved1 = reserved2 = reserved3 = reserved4 = 0;
 
 		// calculate how much space we have left for the extent map
-		int maxSpace = getMaxFreeSpace();
+        if (SanityManager.DEBUG) {
+            // totalSpace used to be incorrect (DERBY-3116), so check it here
+            int maxFreeSpace = getMaxFreeSpace();
+            SanityManager.ASSERT(totalSpace == maxFreeSpace,
+                                 "totalSpace = " + totalSpace +
+                                 ", getMaxFreeSpace() = " + maxFreeSpace);
+        }
 
 		// the pages this extent is going to manage starts from pageNum+1
 		// starting physical offset is pageSize*(pageNum+1) since we have
 		// no logical to physical mapping yet...
-		extent = createExtent(newIdentity.getPageNumber()+1, getPageSize(), 0 /* pagesAlloced */,
maxSpace);
+        extent = createExtent(newIdentity.getPageNumber()+1, getPageSize(),
+                              0 /* pagesAlloced */, totalSpace);
 	}
 
 	private AllocExtent createExtent(long pageNum, int pageSize, int pagesAlloced, int availspace)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/CachedPage.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/CachedPage.java?rev=644698&r1=644697&r2=644698&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/CachedPage.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/CachedPage.java Fri
Apr  4 05:49:09 2008
@@ -857,9 +857,11 @@
             // Just in case memory is low.
             pageData = null; 
 			pageData = new byte[pageSize];
-				
-			usePageBuffer(pageData);
 		}
+
+        // Always call usePageBuffer(), even when we reuse the buffer, so that
+        // totalSpace and friends are recalculated (DERBY-3116).
+        usePageBuffer(pageData);
 	}
 
 



Mime
View raw message