db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mamta Satoor <msat...@gmail.com>
Subject Re: [jira] Commented: (DERBY-421) starting an XA transaction resets the isolation level set with SET CURRENT ISOLATION
Date Mon, 29 Aug 2005 15:55:34 GMT
For some reason, the comment I made in JIRA for Derby-421 didn't show up on 
the list. I have copied it here for reference
 "
As for question 2), regarding the existing field 
isolationLevelExplicitlySet, I see that it gets set to true when the 
isolation level is set using JDBC or SQL. But I don't see it getting reset 
to false. Maybe someone who has worked on this flag can share the purpose of 
this flag. I noticed that this flag gets used later in 
GenericStatement.prepMinion to set the isolation level of the 
CompilerContext. 

What I need is some kind of flag which will get set to true if isolation has 
been set using JDBC or SQL in a given 
transaction. When entering/exiting a global transaction later, I want to see 
if the flag is set to true and if so, set the isolation state in 
BrokeredConnection to that of EmbedConnection (since the isolation state in 
BrokeredConnection can be incorrect if SQL was used to set the isolation 
level). After this state update in BrokeredConnection, I want to reset the 
flag back to false. I don't think I can use isolationLevelExplicitlySet for 
this functionality but more information will clarify this more. 
"
 thanks,
Mamta

 On 8/24/05, Daniel John Debrunner (JIRA) <derby-dev@db.apache.org> wrote: 
> 
> [ 
> http://issues.apache.org/jira/browse/DERBY-421?page=comments#action_12319883]
> 
> Daniel John Debrunner commented on DERBY-421:
> ---------------------------------------------
> 
> A few questions on the patch:
> 
> 1) In BrokeredConnection.setState() the method getIsolationUptoDate() is 
> called. This new method updates the BrokeredConnection state according to 
> the state of the underlying connection, but the purpose and description of 
> the setState() method is the opposite. Thus this method call looks out pf 
> place. Additional comments indicating why it is here would be useful.
> 
> 2) The new field isolationLevelSetUsingSQLorJDBC in 
> GenericLanguageConnectionContext seems to have similar functionality to the 
> existing field isolationLevelExplicitlySet. Are two fields really required? 
> Usually multiple similar state fields is a recipe for bugs.
> 
> 3) The number of new methods to acheive this functionality seems high, I 
> wonder if there is a simpler approach, it would be easier to tell if you 
> could expand on your comment 'And this flag is later used to keep the 
> isolation level state information uptodate in BrokeredConnection.' Could you 
> comment on exactly when this flag is used to reset the state?
> 
> > starting an XA transaction resets the isolation level set with SET 
> CURRENT ISOLATION
> > 
> ------------------------------------------------------------------------------------
> >
> > Key: DERBY-421
> > URL: http://issues.apache.org/jira/browse/DERBY-421
> > Project: Derby
> > Type: Sub-task
> > Components: JDBC
> > Reporter: Kathey Marsden
> > Assignee: Mamta A. Satoor
> > Attachments: derby421XAIsolation082205.txt
> >
> > When an XA Transaction is started the isolation level set with SET 
> CURRENT ISOLATION gets reset to CS.
> > Embedded setTransactionIsolation does not have this problem but this 
> problem is the root cause of DERBY-414 because client implements 
> setTransactionIsolation by sending SET CURRENT ISOLATION
> > $ java TestSetCurrentIsolation
> > Database product: Apache Derby
> > Database version: 10.2.0.0 <http://10.2.0.0> alpha
> > Driver name: Apache Derby Embedded JDBC Driver
> > Driver version: 10.2.0.0 <http://10.2.0.0> alpha
> > SET CURRENT ISOLATION = UR
> > CURRENT ISOLATION: UR
> > getTransactionIsolation:TRANSACTION_READ_UNCOMMITTED:1
> > Isolation level after xa start
> > CURRENT ISOLATION: CS
> > getTransactionIsolation:TRANSACTION_READ_COMMITTED:2
> > $
> > import java.sql.*;
> > import javax.sql.*;
> > import javax.transaction.xa.*;
> > public class TestSetCurrentIsolation
> > {
> > public static void main(String[] args) throws Throwable
> > {
> > try
> > {
> > final org.apache.derby.jdbc.EmbeddedXADataSource ds =
> > new org.apache.derby.jdbc.EmbeddedXADataSource();
> > ds.setDatabaseName("C:\\drivers\\derby\\databases\\SCHEDDB");
> > ds.setUser("dbuser1");
> > ds.setPassword("******");
> > XAConnection xaConn = ds.getXAConnection();
> > Connection conn = xaConn.getConnection();
> > conn.setAutoCommit(true);
> > System.out.println("Database product: " + conn.getMetaData
> ().getDatabaseProductName());
> > System.out.println("Database version: " + conn.getMetaData
> ().getDatabaseProductVersion());
> > System.out.println("Driver name: " + conn.getMetaData
> ().getDriverName());
> > System.out.println("Driver version: " + conn.getMetaData
> ().getDriverVersion());
> > Statement stmt = conn.createStatement();
> > System.out.println("SET CURRENT ISOLATION = UR");
> > stmt.executeUpdate("SET CURRENT ISOLATION = UR");
> > showIsolationLevel(conn);
> > conn.setAutoCommit(false);
> > XAResource xaRes = xaConn.getXAResource();
> > Xid xid = new TestXid(1,(byte) 32, (byte) 32);
> > xaRes.start(xid, XAResource.TMNOFLAGS);
> > System.out.println("Isolation level after xa start");
> > showIsolationLevel(conn);
> >
> > xaRes.end(xid, XAResource.TMSUCCESS);
> > xaRes.rollback(xid);
> > conn.close();
> > xaConn.close();
> > }
> > catch (SQLException sqlX)
> > {
> > System.out.println("Error on thread 1.");
> > do sqlX.printStackTrace();
> > while ((sqlX = sqlX.getNextException()) != null);
> > }
> > catch (Throwable th)
> > {
> > System.out.println("Error on thread 1.");
> > do th.printStackTrace();
> > while ((th = th.getCause()) != null);
> > }
> > }
> > /**
> > * @param conn
> > * @throws SQLException
> > */
> > private static void showIsolationLevel(Connection conn) throws 
> SQLException {
> > PreparedStatement ps = conn.prepareStatement("VALUES CURRENT 
> ISOLATION");
> > ResultSet rs = ps.executeQuery();
> > //ResultSet rs = conn.createStatement().executeQuery("VALUES CURRENT 
> ISOLATION");
> > rs.next();
> > System.out.println("CURRENT ISOLATION: " + rs.getString(1));
> > System.out.println("getTransactionIsolation:" +
> > getIsoLevelName(conn.getTransactionIsolation()));
> > }
> >
> > public static String getIsoLevelName(int level)
> > {
> > switch (level) {
> > case java.sql.Connection.TRANSACTION_REPEATABLE_READ:
> > return "TRANSACTION_REAPEATABLE_READ:" + level;
> >
> > case java.sql.Connection.TRANSACTION_READ_COMMITTED:
> > return "TRANSACTION_READ_COMMITTED:" + level;
> > case java.sql.Connection.TRANSACTION_SERIALIZABLE:
> > return "TRANSACTION_SERIALIZABLE:" + level;
> > case java.sql.Connection.TRANSACTION_READ_UNCOMMITTED:
> > return "TRANSACTION_READ_UNCOMMITTED:" + level;
> > }
> > return "UNEXPECTED_ISO_LEVEL";
> > }
> > }
> 
> --
> This message is automatically generated by JIRA.
> -
> If you think it was sent incorrectly contact one of the administrators:
> http://issues.apache.org/jira/secure/Administrators.jspa
> -
> For more information on JIRA, see:
> http://www.atlassian.com/software/jira
> 
>

Mime
View raw message