jimcoly / h2database

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

The engine does not expect XA rollback without XA prepare. #612

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Then EJB3 methods or Spring method with @Transactional attribute throw an 
exception, the transaction manager rollbacks XA transaction without calling 
prepare() methods first. However, H2 seems to expect transaction prepare before 
rollback. But this only one of possible scenarios. 

What steps will reproduce the problem?
(simple SQL scripts or simple standalone applications are preferred)
1. Run the program.
2. Look at h2\sample.trace.db 
3. See the exception like:

05-25 16:01:07 jdbc[3]: exception
org.h2.jdbc.JdbcSQLException: Transaction 
"XID_3145_222B21030303212103_010203040506060708" not found; SQL statement:
ROLLBACK TRANSACTION XID_3145_222b21030303212103_010203040506060708 [90129-154]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:327)
    at org.h2.message.DbException.get(DbException.java:167)
    at org.h2.message.DbException.get(DbException.java:144)
    at org.h2.engine.Session.setPreparedTransaction(Session.java:829)
    at org.h2.command.dml.TransactionCommand.update(TransactionCommand.java:74)
    at org.h2.command.CommandContainer.update(CommandContainer.java:69)
    at org.h2.command.Command.executeUpdate(Command.java:212)
    at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:177)
    at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:152)
    at org.h2.jdbcx.JdbcXAConnection.rollback(JdbcXAConnection.java:298)
    at sample.Test.main(Test.java:68)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

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

It is expected that the program will write nothing to the trace file and will 
just rollback transaction.

What version of the product are you using? 

I'm using H2 1.3.154.

On what operating system, file system, and virtual machine?

Windows 7 64-bit
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) Client VM (build 19.1-b02, mixed mode, sharing)

Do you know a workaround?

No.

What is your use case, meaning why do you need this feature?

How important/urgent is the problem for you?

Not show stopper, since there are plenty of other database products around. But 
there could be problems with H2 for other users, I'm not sure that data 
eventually rollbacks or not.

Please provide any additional information below.

The possible fix for it would be either to call  
org.h2.engine.Session.setPreparedTransaction with null xid, if there were no 
prepare, or to somehow register transaction with session on XAResource.begin() 
(using "begin transaction" or something like it). I suggest the first variant, 
as it is the simplest one.

Original issue reported on code.google.com by constant...@gmail.com on 25 May 2011 at 12:15

Attachments: