db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1071310 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/services/daemon/IndexStatisticsDaemonImpl.java
Date Wed, 16 Feb 2011 16:57:37 GMT
Author: rhillegas
Date: Wed Feb 16 16:57:37 2011
New Revision: 1071310

URL: http://svn.apache.org/viewvc?rev=1071310&view=rev
Log:
DERBY-5037: Swallow exceptions encountered by the istat thread while the database is being
shutdown.

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=1071310&r1=1071309&r2=1071310&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 Feb 16 16:57:37 2011
@@ -321,7 +321,7 @@ public class IndexStatisticsDaemonImpl
         while (true) {
             try {
                 ConglomerateDescriptor[] cds = td.getConglomerateDescriptors();
-                updateIndexStatsMinion(lcc, td, cds, AS_BACKGROUND_TASK);
+                tryToGatherStats(lcc, td, cds, AS_BACKGROUND_TASK);
                 break;
             } catch (StandardException se) {
                 // At this level, we retry the whole operation. If this happens,
@@ -351,6 +351,47 @@ public class IndexStatisticsDaemonImpl
     }
 
     /**
+     * Try to gather statistics. Fail gracefully if we are being shutdown, e.g., the database
is killed
+     * while we're busy. See DERBY-5037.
+     *
+     * @param lcc language connection context used to perform the work
+     * @param td the table to update index stats for
+     * @param cds the conglomerates to update statistics for (non-index
+     *      conglomerates will be ignored)
+     * @param asBackgroundTask whether the updates are done automatically as
+     *      part of a background task or if explicitly invoked by the user
+     * @throws StandardException if something goes wrong
+     */
+    private void tryToGatherStats(LanguageConnectionContext lcc,
+                                        TableDescriptor td,
+                                        ConglomerateDescriptor[] cds,
+                                        boolean asBackgroundTask)
+            throws StandardException
+    {
+        //
+        // Swallow exceptions raised while we are being shutdown.
+        //
+        try {
+            updateIndexStatsMinion( lcc, td, cds, asBackgroundTask );
+        }
+        catch (StandardException se)
+        {
+            if ( !isShuttingDown( lcc ) ) { throw se; }
+        }
+        // to filter assertions raised by debug jars
+        catch (RuntimeException re)
+        {
+            if ( !isShuttingDown( lcc ) ) { throw re; }
+        }
+    }
+    /** Return true if we are being shutdown */
+    private boolean isShuttingDown( LanguageConnectionContext lcc )
+    {
+        if ( daemonStopped ) { return true; }
+        else { return !lcc.getDatabase().isActive(); }
+    }
+    
+    /**
      * Updates the index statistics for the given table and the specified
      * indexes.
      *



Mime
View raw message