db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davi...@apache.org
Subject svn commit: r344270 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/Clock.java
Date Mon, 14 Nov 2005 23:49:15 GMT
Author: davidvc
Date: Mon Nov 14 15:49:14 2005
New Revision: 344270

URL: http://svn.apache.org/viewcvs?rev=344270&view=rev
Log:
Fix to DERBY-704, submitted by Knut Anders Hatlen

>From Knut:

<quote>
The patch modifies the search for a free slot in the page cache
(org.apache.derby.impl.services.cache.Clock.findFreeItem()) in the
following way:

  1) find out how many invalid pages there are in the page cache
  2) check whether pages that are skipped in the search are invalid
  3) if the number of skipped invalid pages equals the number of
     invalid pages, stop the search for invalid pages
</quote>


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/Clock.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/Clock.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/Clock.java?rev=344270&r1=344269&r2=344270&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/Clock.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/Clock.java Mon Nov
14 15:49:14 2005
@@ -856,18 +856,21 @@
 		// size() is the number of valid entries in the hash table
 
 
-		// no need to sync on getting the sizes since the if
-		// they are wrong we will just not find a invalid entry in
-		// the lookup below.
+		// no need to sync on getting the sizes since if they are
+		// wrong we will discover it in the loop.
 		if (validItemCount < holders.size()) {
 
 			synchronized (this) {
 
-				for (int i = holders.size() - 1; i >= 0 ; i--) {
+				int invalidItems = holders.size() - validItemCount;
+
+				for (int i = holders.size() - 1; (invalidItems > 0) && (i >= 0) ; i--)
{
 					CachedItem item = (CachedItem) holders.get(i);
 
-					if (item.isKept())
+					if (item.isKept()) {
+						if (!item.isValid()) invalidItems--;
 						continue;
+					}
 
 					// found a free item, just use it
 					if (!item.isValid()) {



Mime
View raw message