db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r1339999 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/services/daemon/IndexStatisticsDaemonImpl.java
Date Fri, 18 May 2012 07:04:53 GMT
Author: kristwaa
Date: Fri May 18 07:04:52 2012
New Revision: 1339999

URL: http://svn.apache.org/viewvc?rev=1339999&view=rev
Log:
DERBY-5770: Reduce window of opportunity for queries being compiled without statistics on
istat update 

Moved invalidation to after the new statistics have been written.

Patch file: derby-5770-1a-move_invalidation.diff


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=1339999&r1=1339998&r2=1339999&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
Fri May 18 07:04:52 2012
@@ -556,13 +556,13 @@ public class IndexStatisticsDaemonImpl
 
         // Update the heap row count estimate.
         setHeapRowEstimate(tc, td.getHeapConglomerateId(), numRows);
-        // Invalidate statments accessing the given table.
-        // Note that due to retry logic, swithcing the data dictionary to
-        // write mode is done inside invalidateStatements.
-        invalidateStatements(lcc, td, asBackgroundTask);
         // Drop existing index statistics for this index.
+        if (!lcc.dataDictionaryInWriteMode()) {
+            dd.startWriting(lcc);
+        }
         dd.dropStatisticsDescriptors(table, index, tc);
 
+        boolean conglomerateGone = false; // invalidation control flag
         // Don't write statistics if the table is empty.
         if (numRows == 0) {
             trace(2, "empty table, no stats written");
@@ -596,8 +596,13 @@ public class IndexStatisticsDaemonImpl
                     "rolled back index stats because index has been dropped");
                 lcc.internalRollback();
             }
+            conglomerateGone = (cd == null);
         }
 
+        if (!conglomerateGone) {
+            // Invalidate statments accessing the given table.
+            invalidateStatements(lcc, td, asBackgroundTask);
+        }
         // Only commit tx as we go if running as background task.
         if (asBackgroundTask) {
             lcc.internalCommit(true);
@@ -621,13 +626,11 @@ public class IndexStatisticsDaemonImpl
         // Invalidate compiled statements accessing the table.
         DataDictionary dd = lcc.getDataDictionary();
         DependencyManager dm = dd.getDependencyManager();
-        boolean inWrite = false;
         int retries = 0;
         while (true) {
             try {
-                if (!inWrite) {
+                if (!lcc.dataDictionaryInWriteMode()) {
                     dd.startWriting(lcc);
-                    inWrite = true;
                 }
                 dm.invalidateFor(
                         td, DependencyManager.UPDATE_STATISTICS, lcc);
@@ -644,7 +647,6 @@ public class IndexStatisticsDaemonImpl
                     if (retries > 1) {
                         trace(2, "releasing locks");
                         lcc.internalRollback();
-                        inWrite = false;
                     }
                     trace(2, "lock timeout when invalidating");
                     sleep(100*(1+retries)); // adaptive sleeping...



Mime
View raw message