activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave cawthorn <dave.cawth...@empired.com>
Subject Re: ActiveMQ and Sequoia Database -autocommit issue
Date Mon, 15 May 2006 09:25:44 GMT

I traced through the code to see why I was getting an error reporting that i
was trying to commit a transaction when a connection was in autocommit mode.
I found that in the TransactionContext class's getConnection method the code
inspects the inTx boolean and sets the autocommit property depending on its
value. If it is not in a transaction the connection is left in autocommit
mode. Then I found that in the close method of the TransactionContext the
following:

 if( !inTx ) {
            try {
                executeBatch();
                
                /**
                 * we are not in a transaction so should not be committing
??
                 * This was previously commented out - but had
                 * adverse affects on testing - so it's back!
                 * 
                 */
                try{
                    executeBatch();
                } finally {
                    if (connection != null){
                        connection.commit();
                    }
                }

which was crashing when it got to the commit because the connection was in
autocommit. I suspect there is a query executed at startup that is not
inside a transaction so the autocommit property is not being set to false
and then when close method executes I get an error from the Sequoia driver
cause we are trying to commit on a connection that is set to autocommit.

May I suggest that the TransactionContexts close method be altered to:

 if( !inTx ) {
            try {
                executeBatch();
                
                /**
                 * we are not in a transaction so should not be committing
??
                 * This was previously commented out - but had
                 * adverse affects on testing - so it's back!
                 * 
                 */
                try{
                    executeBatch();
                } finally {
                    if (connection != null && !connection.getAutoCommit()) {
                        connection.commit();
                    }
                }

This fixed the problem for me and i was able to start the broker :-) But i
don't know enough about the code to be aware of any negative side effects...

Dave
--
View this message in context: http://www.nabble.com/ActiveMQ-and-Sequoia-Database--autocommit-issue-t1590803.html#a4389185
Sent from the ActiveMQ - User forum at Nabble.com.


Mime
View raw message