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 kr...@apache.org on 2011/06/08 11:25:31 UTC

svn commit: r1133304 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl: db/DatabaseContextImpl.java sql/catalog/DataDictionaryImpl.java

Author: kristwaa
Date: Wed Jun  8 09:25:31 2011
New Revision: 1133304

URL: http://svn.apache.org/viewvc?rev=1133304&view=rev
Log:
DERBY-5108: Intermittent failure in AutomaticIndexStatisticsTest.testShutdownWhileScanningThenDelete on Windows 

Shut down the istat daemon thread at an earlier stage when the database is
being shut down (user initiated or due to a severe error). This should avoid
the problem where file containers are reopened by the istat daemon after the
container cache has been shut down.

Patch file: derby-5108-2a-early_istats_shutdown_broad.diff


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/db/DatabaseContextImpl.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/db/DatabaseContextImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/db/DatabaseContextImpl.java?rev=1133304&r1=1133303&r2=1133304&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/db/DatabaseContextImpl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/db/DatabaseContextImpl.java Wed Jun  8 09:25:31 2011
@@ -24,6 +24,7 @@ package org.apache.derby.impl.db;
 import org.apache.derby.iapi.services.context.ContextImpl;
 import org.apache.derby.iapi.services.context.ContextManager;
 import org.apache.derby.iapi.services.context.ContextService;
+import org.apache.derby.iapi.sql.dictionary.DataDictionary;
 import org.apache.derby.iapi.services.monitor.Monitor;
 import org.apache.derby.iapi.db.Database;
 import org.apache.derby.iapi.db.DatabaseContext;
@@ -55,6 +56,20 @@ final class DatabaseContextImpl extends 
 
         popMe();
         
+        if (se.getSeverity() >= ExceptionSeverity.DATABASE_SEVERITY) {
+            // DERBY-5108: Shut down the istat daemon thread before shutting
+            // down the various modules belonging to the database. An active
+            // istat daemon thread at the time of shutdown may result in
+            // containers being reopened after the container cache has been
+            // shut down. On certain platforms, this results in database
+            // files that can't be deleted until the VM exits.
+            DataDictionary dd = db.getDataDictionary();
+            // dd is null if the db is an active slave db (replication)
+            if (dd != null) {
+                dd.disableIndexStatsRefresher();
+            }
+        }
+
         if (se.getSeverity() == ExceptionSeverity.DATABASE_SEVERITY) {
 		    ContextService.getFactory().notifyAllActiveThreads(this);
             // This may be called multiple times, but is short-circuited

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java?rev=1133304&r1=1133303&r2=1133304&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java Wed Jun  8 09:25:31 2011
@@ -13768,12 +13768,13 @@ public final class	DataDictionaryImpl
 
     /** {@inheritDoc} */
     public void disableIndexStatsRefresher() {
-        indexStatsUpdateDisabled = true;
-        // NOTE: This will stop the automatic updates of index statistics,
-        //       but users can still do this explicitly (i.e. by invoking
-        //       the SYSCS_UTIL.SYSCS_UPDATE_STATISTICS system procedure).
-        // Set at boot time, we expect it to be non-null.
-        indexRefresher.stop();
+        if (!indexStatsUpdateDisabled) {
+            indexStatsUpdateDisabled = true;
+            // NOTE: This will stop the automatic updates of index statistics,
+            //       but users can still do this explicitly (i.e. by invoking
+            //       the SYSCS_UTIL.SYSCS_UPDATE_STATISTICS system procedure).
+            indexRefresher.stop();
+        }
     }
 
     /** {@inheritDoc} */