Hi all,
I use h2-1.3.174 and I believe that there is a bug inside JdbcXAConnection
in the rollback() method.
I ran into the bug when I simulated an exception during the 2pc.
If rollback() and setAutoCommit(true) are invoked once prepare() has been
called, "ROLLBACK TRANSACTION" throws an exception saying that the current
transaction doesn't exist any more.
Thus rollback() and setAutoCommit(true) should only be called if no prepare
has been executed?
Here's my suggestion (my unit test works with the change):
Original code:
if (isDebugEnabled()) {
debugCode("rollback("+JdbcXid.toString(xid)+");");
}
try {
physicalConn.rollback();
physicalConn.setAutoCommit(true);
if (prepared) {
Statement stat = null;
try {
stat = physicalConn.createStatement();
stat.execute("ROLLBACK TRANSACTION " +
JdbcXid.toString(xid));
} finally {
JdbcUtils.closeSilently(stat);
}
prepared = false;
}
} catch (SQLException e) {
throw convertException(e);
}
currentTransaction = null;
should be
if (isDebugEnabled()) {
debugCode("rollback("+JdbcXid.toString(xid)+");");
}
try {
if (prepared) {
Statement stat = null;
try {
stat = physicalConn.createStatement();
stat.execute("ROLLBACK TRANSACTION " +
JdbcXid.toString(xid));
} finally {
JdbcUtils.closeSilently(stat);
}
prepared = false;
}
else {
physicalConn.rollback();
}
physicalConn.setAutoCommit(true);
} catch (SQLException e) {
throw convertException(e);
}
currentTransaction = null;
Cheers
Markus
--
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/groups/opt_out.