You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2011/03/12 17:45:46 UTC

svn commit: r1080947 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/services/daemon/IndexStatisticsDaemonImpl.java

Author: kahatlen
Date: Sat Mar 12 16:45:46 2011
New Revision: 1080947

URL: http://svn.apache.org/viewvc?rev=1080947&view=rev
Log:
DERBY-5045: Assert failures in UpdateStatisticsTest

Updated statistics shouldn't be inserted into SYSSTATISTICS if the
index has been dropped.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/daemon/IndexStatisticsDaemonImpl.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/daemon/IndexStatisticsDaemonImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/daemon/IndexStatisticsDaemonImpl.java?rev=1080947&r1=1080946&r2=1080947&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/daemon/IndexStatisticsDaemonImpl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/daemon/IndexStatisticsDaemonImpl.java Sat Mar 12 16:45:46 2011
@@ -559,6 +559,18 @@ public class IndexStatisticsDaemonImpl
                     (cd == null ? "n/a" : cd.getDescriptorName()) +
                     " (" + index + "): rows=" + numRows +
                     ", card=" + cardToStr(cardinality));
+
+            // DERBY-5045: When running as a background task, we don't take
+            // intention locks that prevent dropping the table or its indexes.
+            // So there is a possibility that this index was dropped before
+            // we wrote the statistics to the SYSSTATISTICS table. If the table
+            // isn't there anymore, issue a rollback to prevent inserting rows
+            // for non-existent indexes in SYSSTATISTICS.
+            if (asBackgroundTask && cd == null) {
+                log(asBackgroundTask, td,
+                    "rolled back index stats because index has been dropped");
+                lcc.internalRollback();
+            }
         }
 
         // Only commit tx as we go if running as background task.