activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r797685 - in /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc: DefaultDatabaseLocker.java JDBCPersistenceAdapter.java
Date Fri, 24 Jul 2009 23:00:20 GMT
Author: gtully
Date: Fri Jul 24 23:00:20 2009
New Revision: 797685

URL: http://svn.apache.org/viewvc?rev=797685&view=rev
Log:
resolve intermittent hang of JDBCQueueMasterSlaveTest - shutdown of the executor used to check
the db lock during shutdown may cause the shutdown thread to interrupt and die before shutdown
is complete. A wait for shutdown to complete can hang forever. Just cancelling the periodic
tasks is sufficient

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/DefaultDatabaseLocker.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapter.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/DefaultDatabaseLocker.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/DefaultDatabaseLocker.java?rev=797685&r1=797684&r2=797685&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/DefaultDatabaseLocker.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/DefaultDatabaseLocker.java
Fri Jul 24 23:00:20 2009
@@ -146,7 +146,7 @@
             }
         } catch (Exception e) {
             LOG.error("Failed to update database lock: " + e, e);
-        }finally {
+        } finally {
             if (statement != null) {
                 try {
                     statement.close();

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapter.java?rev=797685&r1=797684&r2=797685&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapter.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapter.java
Fri Jul 24 23:00:20 2009
@@ -73,7 +73,7 @@
     private JDBCAdapter adapter;
     private MemoryTransactionStore transactionStore;
     private ScheduledThreadPoolExecutor clockDaemon;
-    private ScheduledFuture clockTicket;
+    private ScheduledFuture<?> cleanupTicket, keepAliveTicket;
     private int cleanupPeriod = 1000 * 60 * 5;
     private boolean useExternalMessageReferences;
     private boolean useDatabaseLock = true;
@@ -196,7 +196,7 @@
             } else {
                 service.start();
                 if (lockKeepAlivePeriod > 0) {
-                    getScheduledThreadPoolExecutor().scheduleAtFixedRate(new Runnable() {
+                    keepAliveTicket = getScheduledThreadPoolExecutor().scheduleAtFixedRate(new
Runnable() {
                         public void run() {
                             databaseLockKeepAlive();
                         }
@@ -212,7 +212,7 @@
 
         // Cleanup the db periodically.
         if (cleanupPeriod > 0) {
-            clockTicket = getScheduledThreadPoolExecutor().scheduleAtFixedRate(new Runnable()
{
+            cleanupTicket = getScheduledThreadPoolExecutor().scheduleAtFixedRate(new Runnable()
{
                 public void run() {
                     cleanup();
                 }
@@ -221,14 +221,16 @@
     }
 
     public synchronized void stop() throws Exception {
-        if (clockTicket != null) {
-            clockTicket.cancel(true);
-            clockTicket = null;
-        }
-        if (clockDaemon != null) {
-            clockDaemon.shutdown();
-            clockDaemon = null;
+        if (cleanupTicket != null) {
+            cleanupTicket.cancel(true);
+            cleanupTicket = null;
+        }
+        if (keepAliveTicket != null) {
+            keepAliveTicket.cancel(false);
+            keepAliveTicket = null;
         }
+        
+        // do not shutdown clockDaemon as it may kill the thread initiating shutdown
         DatabaseLocker service = getDatabaseLocker();
         if (service != null) {
             service.stop();



Mime
View raw message