google-code-export / h2database

Automatically exported from code.google.com/p/h2database
0 stars 1 forks source link

Rollback not working correctly in cluster mode. #259

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. create cluster
2. connect cluster and set auto commit false
3. insert and rollback.

sql> create table hoge(id int, txt varchar);
(Update count: 0, 8 ms)
sql> set autocommit false;
(Update count: 0, 2 ms)
sql> insert into hoge values (1,'tt');
(Update count: 1, 2 ms)
sql> select * from hoge;
ID         |TXT
1          |tt
(1 row, 33 ms)
sql> rollback;
(Update count: 0, 2 ms)
sql> select * from hoge;
ID         |TXT
1          |tt
(1 row, 3 ms)
sql> select autocommit() ;
AUTOCOMMIT()
FALSE
(1 row, 7 ms)

What is the expected output? What do you see instead?

Please use labels and text to provide additional information.

I tried to reproduce this problem on some versions.

1.2.137,1.2.140,1.2.141 and 1.2.142 seem to be no problem.
But 1.2.143 and 1.2.145 reproduced this problem.

I think org.h2.test.db.TestCluster#testCase() is not correct.

org.h2.test.db.TestCluster
81:        conn = DriverManager.getConnection(urlCluster, user, password);
82:        stat = conn.createStatement();
83:        ResultSet rs = stat.executeQuery("select * from test");
84:        assertTrue(rs.next());
85:        assertEquals(1, rs.getInt(1));
**:         assertFalse(rs.next()); //Is this insufficient?
86:        conn.close();

Original issue reported on code.google.com by litail...@gmail.com on 24 Nov 2010 at 5:33

GoogleCodeExporter commented 9 years ago
Hi,

The problem is that the following command: 

> set autocommit false;

doesn't actually disable autocommit (or better: the client doesn't notice it 
does, because in cluster mode autocommit is anyway disabled). The workaround is 
to use the JDBC API:

conn.setAutoCommit(false);

I'm not sure yet how to solve this problem.

Original comment by thomas.t...@gmail.com on 28 Nov 2010 at 4:15

GoogleCodeExporter commented 9 years ago
This is now documented as a limitation:
http://h2database.com/html/advanced.html#clustering
= Clustering Algorithm and Limitations =
The SQL statement SET AUTOCOMMIT FALSE is not supported in the cluster mode. To 
disable autocommit, the method Connection.setAutoCommit(false) needs to be 
called. 

Therefore, I'm resolving this issue as 'won't fix'.

Original comment by thomas.t...@gmail.com on 12 Dec 2010 at 12:08