db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r1076445 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl: services/daemon/IndexStatisticsDaemonImpl.java sql/catalog/DataDictionaryImpl.java
Date Wed, 02 Mar 2011 22:51:47 GMT
Author: kristwaa
Date: Wed Mar  2 22:51:47 2011
New Revision: 1076445

URL: http://svn.apache.org/viewvc?rev=1076445&view=rev
Log:
DERBY-5087: NPE in istat daemon when encountering critical exception during shutdown

Don't null out the index stats refresher reference in the data dictionary when
stopping the module.
Removed unnecessary variable 'daemonStopped', used existing 'daemonDisabled'
instead.

Patch file: derby-5087-1a-npe_on_shutdown.diff

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/daemon/IndexStatisticsDaemonImpl.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/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=1076445&r1=1076444&r2=1076445&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
Wed Mar  2 22:51:47 2011
@@ -131,8 +131,6 @@ public class IndexStatisticsDaemonImpl
     /** Tells if the daemon has been disabled. */
     // @GuardedBy("queue")
     private boolean daemonDisabled;
-    /** Tells if the daemon has been stopped. */
-    private volatile boolean daemonStopped;
     /** The context manager for the worker thread. */
     private final ContextManager ctxMgr;
     /** The language connection context for the worker thread. */
@@ -388,8 +386,12 @@ public class IndexStatisticsDaemonImpl
     /** Return true if we are being shutdown */
     private boolean isShuttingDown( LanguageConnectionContext lcc )
     {
-        if ( daemonStopped ) { return true; }
-        else { return !lcc.getDatabase().isActive(); }
+        synchronized (queue) {
+            if (daemonDisabled ){
+                return true;
+            }
+        }
+        return !lcc.getDatabase().isActive();
     }
     
     /**
@@ -849,9 +851,8 @@ public class IndexStatisticsDaemonImpl
      * first time the method is invoked.
      */
     public void stop() {
-        if (!daemonStopped) {
-            daemonStopped = true;
-            synchronized (queue) {
+        synchronized (queue) {
+            if (!daemonDisabled) {
                 StringBuffer sb = new StringBuffer(100);
                 sb.append("stopping daemon, active=").
                         append(runningThread != null).

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=1076445&r1=1076444&r2=1076445&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 Mar  2 22:51:47 2011
@@ -970,9 +970,10 @@ public final class	DataDictionaryImpl
     public void stop() {
         // Shut down the index statistics refresher, mostly to make it print
         // processing stats
+        // Not sure if the reference can be null here, but it may be possible
+        // if multiple threads are competing to boot and shut down the db.
         if (indexRefresher != null) {
             indexRefresher.stop();
-            indexRefresher = null;
         }
     }
 



Mime
View raw message