Hi, Version 1.4.x, when using the MVStore, only supports the MVCC model, and read committed. Setting the transaction isolation level to serializable basically has no effect there. This is a limitation (of the TransactionStore), I will need to document this. Serializable could be implemented, but it doesn't have priority for me right now.
Version 1.3.x, and 1.4.x when the MVStore is disabled (append ";mv_store=false" to the database URL) will use table level locking. In this case, you will get a "timeout trying to lock table" at the insert statement. > Am I bananas This question I can't answer, sorry :-) Regards, Thomas On Wednesday, January 28, 2015, loki2302 <[email protected]> wrote: > Hi everyone, > > I'm seeing quite a weird behavior when trying to use serializable > transaction isolation level with H2. Here's my test case: > > try(Connection connection1 = DriverManager.getConnection(...)) { > connection1.setAutoCommit(false); > > try(Connection connection2 = DriverManager.getConnection(...)) { > > connection2.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); > connection2.setAutoCommit(false); > > assertEquals(0, selectAll(connection1)); // A: select * from XXX > assertEquals(0, selectAll(connection2)); // B: select * from XXX > > insertOne(connection1); // A: insert into XXX > > assertEquals(1, selectAll(connection1)); // A: select * from XXX > assertEquals(0, selectAll(connection2)); // B: select * from XXX > > connection1.commit(); > > assertEquals(1, selectAll(connection1)); // A: select * from XXX > assertEquals(0, selectAll(connection2)); // B: select * from XXX > // ^^^ here it says there's 1 row, the one inserted by connection1 > } > } > (the complete test is here > <https://gist.github.com/loki2302/26f3c052f7e73fd22604>) > > Briefly, there are 2 concurrent connections, both read the same data in > parallel, one of them writes the data somewhere in a middle. I expect the > second connection not to see these changes, but it actually sees them. > Could anyone please clarify if it should work the way I expect or not? > > -- > You received this message because you are subscribed to the Google Groups > "H2 Database" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <javascript:_e(%7B%7D,'cvml','h2-database%[email protected]');> > . > To post to this group, send email to [email protected] > <javascript:_e(%7B%7D,'cvml','[email protected]');>. > Visit this group at http://groups.google.com/group/h2-database. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/h2-database. For more options, visit https://groups.google.com/d/optout.
