mirror of https://github.com/apache/activemq.git
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
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@797685 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
444412f0df
commit
a8d3908586
|
@ -146,7 +146,7 @@ public class DefaultDatabaseLocker implements DatabaseLocker {
|
|||
}
|
||||
} catch (Exception e) {
|
||||
LOG.error("Failed to update database lock: " + e, e);
|
||||
}finally {
|
||||
} finally {
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
|
|
|
@ -73,7 +73,7 @@ public class JDBCPersistenceAdapter extends DataSourceSupport implements Persist
|
|||
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 @@ public class JDBCPersistenceAdapter extends DataSourceSupport implements Persist
|
|||
} else {
|
||||
service.start();
|
||||
if (lockKeepAlivePeriod > 0) {
|
||||
getScheduledThreadPoolExecutor().scheduleAtFixedRate(new Runnable() {
|
||||
keepAliveTicket = getScheduledThreadPoolExecutor().scheduleAtFixedRate(new Runnable() {
|
||||
public void run() {
|
||||
databaseLockKeepAlive();
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ public class JDBCPersistenceAdapter extends DataSourceSupport implements Persist
|
|||
|
||||
// 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 class JDBCPersistenceAdapter extends DataSourceSupport implements Persist
|
|||
}
|
||||
|
||||
public synchronized void stop() throws Exception {
|
||||
if (clockTicket != null) {
|
||||
clockTicket.cancel(true);
|
||||
clockTicket = null;
|
||||
if (cleanupTicket != null) {
|
||||
cleanupTicket.cancel(true);
|
||||
cleanupTicket = null;
|
||||
}
|
||||
if (clockDaemon != null) {
|
||||
clockDaemon.shutdown();
|
||||
clockDaemon = 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();
|
||||
|
|
Loading…
Reference in New Issue