Bug #506: serializable transaction does may commit in jdbc

From: pgsql-bugs(at)postgresql(dot)org
To: pgsql-bugs(at)postgresql(dot)org
Subject: Bug #506: serializable transaction does may commit in jdbc
Date: 2001-10-31 04:59:17
Message-ID: 200110310459.f9V4xHZ46679@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Bram Kivenko (postgres(at)kivco(dot)com) reports a bug with a severity of 2
The lower the number the more severe it is.

Short Description
serializable transaction does may commit in jdbc

Long Description
Sequence of events:
(using the jdbc driver 7.1.3 on linux 2.4.x, jdk2 1.3.1

commit
set transaction isolation level serializable
autocommit(false)
commit

select * from non_existing_table
... catch exception ...
create table non_existing_table (...);
commit
autocommit(true)
set transaction isolation readable

It seems that the table cannot be created once a failed
query occurs inside the serializable transaction.

This does _NOT_ occur when running psql and doing much
the same thing -- it only happens with the JDBC driver.

Sample Code
public class ... {
Connection conn;

protected int getIsolation() throws Exception {
int origIsolation;

try {
origIsolation = conn.getTransactionIsolation();
if ( origIsolation != conn.TRANSACTION_SERIALIZABLE ) {
conn.commit();
conn.setTransactionIsolation(conn.TRANSACTION_SERIALIZABLE);
conn.setAutoCommit(false);
conn.commit();
}
} catch ( SQLException e ) {
throw new Exception(e.toString());
}
return origIsolation;
}

protected void resetIsolation(int origIsolation)
throws Exception {
try {
if ( origIsolation != conn.TRANSACTION_SERIALIZABLE ) {
conn.commit();
conn.setAutoCommit(true);
conn.setTransactionIsolation(origIsolation);
}
} catch ( SQLException e ) {
throw new Exception(e.toString());
}
}

protected void init() throws Exception {
int origIsolation = getIsolation();
try {
ResultSet rs;
rs = conn.createStatement().executeQuery(
"SELECT * " +
"FROM " + tableName + " " +
"WHERE 1 = 0; ");
rs.close();
} catch ( SQLException e ) {
try {
conn.createStatement().executeUpdate(
"CREATE TABLE " + tableName +
" ( id int ); ");
commit();
} catch ( SQLException e2 ) {
throw new Exception(e2);
}
} finally {
resetIsolation(origIsolation);
}
}

No file was uploaded with this report

Browse pgsql-bugs by date

  From Date Subject
Next Message Thomas Yackel 2001-10-31 20:20:24 user authentication crash by Erik Luke (20-08-2001; 1.3kb)
Previous Message Tom Lane 2001-10-30 20:50:39 Re: Triggers cause backend crash