Hi Thomas,

On 31 Aug., 19:49, Thomas Mueller <[email protected]>
wrote:
> Hi,
>
> I have two questions:
>
> - What is your use case?

I started to apply the performance tips from
http://www.h2database.com/html/performance.html#database_performance_tuning
and connection pooling is one of the first hints.
My app uses transactions and therefore I need to call
setAutoCommit(false) on each connection I get from the connection
pool. I wonder about the JDBC specification which declares the
autocommit(true) behaviour.

The reason I am asking about that is that I have seen from some
stacktraces that the setAutoCommit(false) method is blocked if another
query is running:
   java.lang.Thread.State: BLOCKED (on object monitor)
        at org.h2.command.Command.executeUpdate(Command.java:192)
        - waiting to lock <0x180acf98> (a org.h2.engine.Database)
        at org.h2.jdbc.JdbcConnection.setAutoCommit(JdbcConnection.java:370)
        - locked <0x204ff6f0> (a org.h2.jdbcx.JdbcXAConnection
$PooledJdbcConnection)
       ...

   java.lang.Thread.State: RUNNABLE
        at java.io.RandomAccessFile.readBytes(Native Method)
        at java.io.RandomAccessFile.read(RandomAccessFile.java:322)
        at java.io.RandomAccessFile.readFully(RandomAccessFile.java:381)
        at org.h2.store.FileStore.readFully(FileStore.java:281)
        at org.h2.store.PageStore.readPage(PageStore.java:1099)
        - locked <0x180acf98> (a org.h2.engine.Database)
        at org.h2.store.PageStore.getPage(PageStore.java:559)
        - locked <0x180acf98> (a org.h2.engine.Database)
        at org.h2.index.PageDataIndex.getPage(PageDataIndex.java:218)
        ...
        at org.h2.index.MultiVersionCursor.get(MultiVersionCursor.java:81)
        - locked <0x180acf98> (a org.h2.engine.Database)
        at org.h2.index.IndexCursor.get(IndexCursor.java:209)
        ...
        at org.h2.command.CommandContainer.query(CommandContainer.java:80)
        at org.h2.command.Command.executeQuery(Command.java:132)
        - locked <0x180acf98> (a org.h2.engine.Database)
        at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:172)
        - locked <0x188fe078> (a org.h2.engine.Session)
        at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:151)

My unsophisticated idea is that the ConnectionPool need not to reset
autocommit to true if I return a connection to the pool. So this would
save a setAutoCommit(true) and setAutoCommit(false) call.

By the way: I am using MVCC=TRUE. MULTI_THREADED=YES is no option for
me because I have problems with the possible deadlock situation
(discussed in some other threads).

> - Does another connection pool support such a feature?

It seems to me that PostgreSQL supports this (table 31-2):
http://www.postgresql.org/files/documentation/books/pghandbuch/html/jdbc-datasource.html

>
> Regards,
> Thomas

Uli

-- 
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