Hi,

The problem seems to be: there is an update in the table
ACTIVEMQ_LOCK, but this transaction is never committed. This causes
the transaction log to grow without bounds (the head of the
transaction log can't be removed because it contains an uncommitted
transaction).

As far as I understand, you are using Apache ActiveMQ, which in turn
is using the "DefaultDatabaseLocker". From looking at the ActiveMQ
source code, it would be better to use the TransactDatabaseLocker,
because it uses SELECT ... FOR UPDATE (which is not problematic)
instead of an UPDATE statement.

This is also a problem for other database, for example Apache Derby. I
wrote a test case:
http://h2database.com/p.html#4f101b6ff822ec3208c421f08d1a4188 This
problem is also described here:
http://old.nabble.com/Running-ActiveMQ-and-having-a-database-failover-td28233397.html
- a workaround described there is "if you're sure that only one broker
will use database, you can try setting useDatabaseLock to false". This
sounds a bit dangerous however.

The best solution seems to use the TransactDatabaseLocker - it looks
like you can configure that
http://activemq.apache.org/xbean-xml-reference-41.html - in the
<jdbcPersistenceAdapter> element,  property databaseLocker =
"org.apache.activemq.store.jdbc.adapter.TransactDatabaseLocker" - if
this doesn't work please tell us. However, using the MVCC mode will
again result in the same problem. Therefore, please do not use the
MVCC mode in this case. I don't actually have any experience using
ActiveMQ, could you tell us in what file this configuration resides?

Regards,
Thomas

P.S. I will add the following documentation:

== Using Apache ActiveMQ ==

When using H2 as the backend database for Apache ActiveMQ, please use
the TransactDatabaseLocker instead of the default locking mechanism.
Otherwise the database file will grow without bounds. The problem is
that the default locking mechanism uses an uncommitted UPDATE
transaction, which keeps the transaction log from shrinking (causes
the database file to grow). Instead of using an UPDATE statement, the
TransactDatabaseLocker uses SELECT ... FOR UPDATE which is not
problematic. To use it, change the ApacheMQ configuration element
<jdbcPersistenceAdapter> element, property databaseLocker =
"org.apache.activemq.store.jdbc.adapter.TransactDatabaseLocker".
However, using the MVCC mode will again result in the same problem.
Therefore, please do not use the MVCC mode in this case. Another (more
dangerous) solution is to set useDatabaseLock to false.

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to