activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dejan Bosanac <dejan.bosa...@ttmsolutions.com>
Subject Re: activemq in failover mode prints that derbydb is already locked
Date Wed, 08 Oct 2008 07:33:49 GMT
Hi,

can you create a patch a submit it with the JIRA issue
(http://issues.apache.org/activemq/browse/AMQ)

Cheers

-- 
Dejan Bosanac


http://www.ttmsolutions.com - get a free ActiveMQ user guide

ActiveMQ in Action - http://www.manning.com/snyder/
Scripting in Java - http://www.scriptinginjava.net



gimel wrote:
> Hi all,
>
> I'm running 2 brokers (activemq 5.1.0) on 2 different machines, in failover
> mode, where the shared folder is on NAS.
> I run into a certain problem (too many times) that as Broker A falls, Broker
> B is coming up, but the activemq fails to start the derbydb.
>
> error is like :
> 2008-09-21 03:23:01,783 [erSimpleAppMain] DEBUG JDBCPersistenceAdapter -
> Could not get JDBC connection: Failed to start database 'derbydb', see the
> next exception for details., due to: Another instance of Derby may have
> already booted the database \\IP\broker\derbydb.
> ERROR XSDB6: Another instance of Derby may have already booted the database
> \\IP\broker\derbydb.
>
> partial stack-trace :
> at org.apache.derby.jdbc.EmbeddedDataSource.getConnection(Unknown Source)
>  at
> org.apache.activemq.store.jdbc.TransactionContext.getConnection(TransactionContext.java:54)
>  at
> org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.createAdapter(JDBCPersistenceAdapter.java:294)
>  at
> org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.getAdapter(JDBCPersistenceAdapter.java:249)
>  at
> org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.start(JDBCPersistenceAdapter.java:155)
>  at
> org.apache.activemq.store.journal.JournalPersistenceAdapter.start(JournalPersistenceAdapter.java:226)
>  at
> org.apache.activemq.broker.BrokerService.createRegionBroker(BrokerService.java:1577)
>  at
> org.apache.activemq.broker.BrokerService.createBroker(BrokerService.java:1530)
>  at
> org.apache.activemq.broker.BrokerService.getBroker(BrokerService.java:540)
>  at org.apache.activemq.broker.BrokerService.start(BrokerService.java:444)
>
> i know, i could also ask the derby developers, but i see that a retry for
> the connection is working as well. i think i'd try to patch the
> org/apache/activemq/store/jdbc/TransactionContext.java,
> and i'd like you to tell me which jars i need to modify in the broker.
> also, if possible, i'd love to get an opinion on the method i've modified in
> this class.
> i simply added retries, and after 5 times, i quit, in order to let the other
> broker to try as well :
>
>
>     public Connection getConnection() throws IOException {
>         boolean shouldRetry = true;
>         final int MAX_RETRIES = 5;
>         final int SLEEP_INTERVAL = 1000;
>
>         for (int countLoops = 0 ; (countLoops < MAX_RETRIES) && shouldRetry;
> ++countLoops)
>         {
>             if (connection == null) {
>                 try {
>                     connection = dataSource.getConnection();
>                     boolean autoCommit = !inTx;
>                     if (connection.getAutoCommit() != autoCommit) {
>                         connection.setAutoCommit(autoCommit);
>                     }
>                     shouldRetry = false;
>                 } catch (SQLException e) {
>                     JDBCPersistenceAdapter.log("Could not get JDBC
> connection: ", e);
>                     LOG.debug(" *** retries count = " + countLoops, e);
>                     if (countLoops + 1 == MAX_RETRIES)
>                     {
>                         IOException ioe = IOExceptionSupport.create(e);
>                         LOG.debug("gave up on trying to reconnect to the DB
> after " + MAX_RETRIES + "retries !!!",
>                                 ioe);
>                         System.exit(0);
>                     }
>                     try {
>                         // if reached the 'catch', and didn't throw an
> exception, better sleep ...
>                         Thread.sleep(SLEEP_INTERVAL);
>                     } catch (InterruptedException e1) {
>                     }
>                 }
>
>                 if (!shouldRetry)
>                 {
>                     try {
>                        
> connection.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
>                     } catch (Throwable e) {
>                     }
>                 }
>             }
>         }
>         return connection;
>     }
>
>
> thanks in advance,
> gimel
>   



Mime
View raw message