db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r644967 - in /db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data: AllocPage.java CachedPage.java
Date Fri, 04 Apr 2008 22:30:57 GMT
Author: kahatlen
Date: Fri Apr  4 15:30:55 2008
New Revision: 644967

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

Merged fix from trunk (revision 644698).

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

Modified: db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/AllocPage.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/AllocPage.java?rev=644967&r1=644966&r2=644967&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/AllocPage.java
(original)
+++ db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/AllocPage.java
Fri Apr  4 15:30:55 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/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/CachedPage.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/CachedPage.java?rev=644967&r1=644966&r2=644967&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/CachedPage.java
(original)
+++ db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/CachedPage.java
Fri Apr  4 15:30:55 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