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/03/03 01:01:56 UTC

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

Author: kristwaa
Date: Thu Mar  3 00:01:55 2011
New Revision: 1076462

URL: http://svn.apache.org/viewvc?rev=1076462&view=rev
Log:
DERBY-5082: ShutdownException in ContextManager.checkInterrupt() during shutdown

The fix is two-fold:
 a) Avoid destroying tx, which will fail, if the database is [being] shut down.
 b) If destroying tx, catch ShutdownException in case someone shuts down the
    database under our feet.

Added a break to make the flow clearer (also avoids an unnecessary trace-line).

Patch file: derby-5082-1a-fix.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=1076462&r1=1076461&r2=1076462&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 Thu Mar  3 00:01:55 2011
@@ -741,6 +741,7 @@ public class IndexStatisticsDaemonImpl
                         tc = null;
                         daemonLCC = null;
                         queue.clear();
+                        break;
                     }
                     if (queue.isEmpty()) {
                         trace(1, "queue empty");
@@ -863,8 +864,14 @@ public class IndexStatisticsDaemonImpl
                 log(AS_BACKGROUND_TASK, null, sb.toString());
                 // If there is no running thread and the daemon lcc is still
                 // around, destroy the transaction and clear the lcc reference.
-                if (runningThread == null && daemonLCC != null) {
-                    daemonLCC.getTransactionExecute().destroy();
+                if (runningThread == null && daemonLCC != null &&
+                        !isShuttingDown(daemonLCC)) {
+                    // try/catch as safe-guard against shutdown race condition.
+                    try {
+                        daemonLCC.getTransactionExecute().destroy();
+                    } catch (ShutdownException se) {
+                        // Ignore
+                    }
                     daemonLCC = null;
                 }
                 daemonDisabled = true;