db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1088495 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/sql/dictionary/TableDescriptor.java testing/org/apache/derbyTesting/functionTests/tests/lang/UpdateStatisticsTest.java
Date Mon, 04 Apr 2011 08:01:00 GMT
Author: kahatlen
Date: Mon Apr  4 08:00:59 2011
New Revision: 1088495

URL: http://svn.apache.org/viewvc?rev=1088495&view=rev
Log:
DERBY-5153: Intermittent ASSERT FAILED Internal Error-- statistics not found in selectivityForConglomerate
when running InterruptResilienceTest

Removed the failing asserts and enabled the test case that exercises the code.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TableDescriptor.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UpdateStatisticsTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TableDescriptor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TableDescriptor.java?rev=1088495&r1=1088494&r2=1088495&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TableDescriptor.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TableDescriptor.java
Mon Apr  4 08:00:59 2011
@@ -1396,6 +1396,9 @@ public class TableDescriptor extends Tup
 	 * numKeys. This basically returns the reciprocal of the number of unique
 	 * values in the leading numKey columns of the index. It is assumed that
 	 * statistics exist for the conglomerate if this function is called.
+     * However, no locks are held to prevent the statistics from being dropped,
+     * so the method also handles the case of missing statistics by using a
+     * heuristic to estimate the selectivity.
 	 *
 	 * @param cd		ConglomerateDescriptor (Index) whose
 	 * cardinality we are interested in.
@@ -1407,22 +1410,6 @@ public class TableDescriptor extends Tup
 											 int numKeys) 
 		throws StandardException
 	{
-		if (!statisticsExist(cd))
-		{
-			if (SanityManager.DEBUG)
-			{
-				SanityManager.THROWASSERT("no statistics exist for conglomerate"
-										  + cd);
-			}
-			else 
-			{
-				double selectivity = 0.1;
-				for (int i = 0; i < numKeys; i++)
-					selectivity *= 0.1;
-				return selectivity;
-			}
-		}
-		
 		UUID referenceUUID = cd.getUUID();
 
 		List sdl = getStatistics();
@@ -1438,10 +1425,10 @@ public class TableDescriptor extends Tup
 			
 			return statDesc.getStatistic().selectivity((Object[])null);
 		}
-		
-		if (SanityManager.DEBUG)
-			SanityManager.THROWASSERT("Internal Error-- statistics not found in selectivityForConglomerate.\n
cd = " + cd + "\nnumKeys = " + numKeys);
-		return 0.1;				// shouldn't come here.
+
+        // Didn't find statistics for these columns. Assume uniform 10%
+        // selectivity for each column in the key.
+        return Math.pow(0.1, numKeys);
 	}
 
 	/** @see TupleDescriptor#getDescriptorName */

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UpdateStatisticsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UpdateStatisticsTest.java?rev=1088495&r1=1088494&r2=1088495&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UpdateStatisticsTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UpdateStatisticsTest.java
Mon Apr  4 08:00:59 2011
@@ -214,10 +214,8 @@ public class UpdateStatisticsTest extend
     /**
      * Regression test case for DERBY-5153. Compilation in parallel with
      * update of statistics sometimes failed on debug builds.
-     *
-     * The test case should be disabled until the bug is fixed.
      */
-    public void disabled_testParallelCompilationAndUpdate() throws Exception {
+    public void testParallelCompilationAndUpdate() throws Exception {
         setAutoCommit(false);
 
         // Create and populate a test table with a multi-column index.



Mime
View raw message