db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mamta Satoor <msat...@gmail.com>
Subject XA transactions and state information
Date Wed, 03 Aug 2005 15:10:27 GMT
Hi,
 From Dan's explanation on Derby-421 (starting an XA transaction resets the 
isolation level set with SET CURRENT ISOLATION) about various transaction 
states, what I understand is that local transaction and global transaction 
have to maintain their own states. I wrote a simple test program to check 
this behavior and it seems like Derby is not doing so. 
 My test program gets a XA connection which is part of the local 
transaction. Derby's default isolation level is CS and that is what the 
connection object has at this point. I change the isolation level to UR 
within the local transaction. Now, the XA connection joins a global 
transaction. I had expected that the isolation level of the connection 
inside the global transaction would be the default isolation level CS but 
that is not the case, instead, it is set to the isolation level UR which is 
what the local transaction had it. Within the global transaction, I change 
the isolation level to RS and then exit the global transaction so the 
connection is now attached to the local transaction. The isolation level at 
this point is set to RS rather than UR. This seems incorrect. Any comments?
 Following is the code snippet
 
EmbeddedXADataSource dscsx = new EmbeddedXADataSource();
dscsx.setDatabaseName("c:/dellater/db1");
XADataSource dsx = dscsx;
XAConnection xac = dsx.getXAConnection();
con = xac.getConnection();
s = con.createStatement();
System.out.println("default isolation level should be CS? " + 
con.getTransactionIsolation());
dumpRS(s.executeQuery("VALUES CURRENT ISOLATION"));
System.out.println("change the isolation level with 
setTransactionIsolation");
con.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
System.out.println("new isolation level should be UR? " + 
con.getTransactionIsolation());
dumpRS(s.executeQuery("VALUES CURRENT ISOLATION"));

XAResource xar = xac.getXAResource();
Xid xid = new cdsXid(1, (byte) 35, (byte) 47);
xar.start(xid, XAResource.TMNOFLAGS);

s = con.createStatement();
System.out.println("isolation level inside global transaction is " + 
con.getTransactionIsolation());
dumpRS(s.executeQuery("VALUES CURRENT ISOLATION"));
System.out.println("change the isolation level inside global transaction 
with setTransactionIsolation");
con.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
System.out.println("new isolation level should be RS? " + 
con.getTransactionIsolation());
dumpRS(s.executeQuery("VALUES CURRENT ISOLATION"));

xar.end(xid, XAResource.TMSUCCESS);
xar.rollback(xid);

System.out.println("isolation level outside global transaction should be UR? 
" + con.getTransactionIsolation());
dumpRS(s.executeQuery("VALUES CURRENT ISOLATION"));
thanks,
Mamta

Mime
View raw message