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