Isolation level configuration

Hello there,
I am converting our not-transaction based application to use transactions. As I want to reduce the performance impact I am configuring some transactions to some lesser isolation levels. As far as I understand from the docs, the general way to do it is to set proper isolation level in TransactionConfig when creating a transaction.
But from what I see in the docs, it's possible to use PrimaryIndex.get() third parameter (lockMode) to specify isolation for the specific operation as well.
So my question is: what are props and cons of per-operation isolation configuration compared to per-transaction isolation configuration?
I.e. I'm considering which approach is better:
1.
TransactionConfig txnConfig = new TransactionConfig();
txnConfig.setReadUncommitted(true);
Transaction txn = myEnv.beginTransaction(null, txnConfig);
for (id : idList)
primaryIndex.get(txn, id, null);
2.
Transaction txn = myEnv.beginTransaction(null, null);
for (id : idList)
primaryIndex.get(txn, id, LockMode.READ_UNCOMMITTED);
In general I understand that specifying isolation on per-operation basis probably was intended to be used as a tool for locally changing the general transaction setting like
3.
TransactionConfig txnConfig = new TransactionConfig();
txnConfig.setReadUncommitted(true);
Transaction txn = myEnv.beginTransaction(null, txnConfig);
for (id : idList)
primaryIndex.get(txn, id, id == 5? LockMode.READ_COMMITTED : null);
but I want to know if the 2nd approach is legal and would not lead to some bad consequences.

Hello Linda,
Thanks for clarification!
Still your last note makes me think that I'm doing something that I should not. When you say :
it does seem unusual to have a transaction where you always choose to use READ_UNCOMMITTEDdo you mean that I don't have to use a transaction for a read-only operations sequence?
Here's my use-case. In my application I have 2 types of threads:
Threads of the 1st type would just update some record in the DB. I do it like this:
Transaction txn = myEnv.beginTransaction(null, null);
Record record = primaryIndex.get(txn, id, LockMode.RMW);
record.update(...);
primaryIndex.putNoReturn(txn, record);
txn.commit();
I'm using LockMode.RMW to prevent other threads from writing this record without reading it first.
Threads of the 2nd type would perform reading of some set of records. I do it like this:
Transaction txn = myEnv.beginTransaction(null, null);
int result = 0;
for (id : idList)
Record record = primaryIndex.get(txn, id, LockMode.READ_UNCOMMITTED);
result += record.getValue();
txn.commit();
or
Transaction txn = myEnv.beginTransaction(null, null);
int result = 0;
EntityCursor<Record> cursor = primaryIndex.entities(txn, CursorConfig.READ_UNCOMMITTED);
for (Record record : cursor)
result += record.getValue();
cursor.close()
txn.commit();
I am using READ_UNCOMMITTED there to reduce chances of locking, as I'm not really interested whether I get the value before it gets updated by some 1st type transaction or after.
Can you give me any advice on how I should do it in more correct way?
Should I just remove the transaction from the 2nd type of threads (so there would be no questions on what does the txn.commit() commits there)?
Does the fact that I'm using LockMode.READ_UNCOMMITTED means that I can get the record in some internally-inconsistent state?

Similar Messages

  • Can you set isolation levels of message-driven bean transactions?

    The problem: I have 3 different message-driven beans which each get a different type of message, except for a field that is common to all. That field is used as the primary key of an entity object. The message-driven beans configured to use a container managed transaction. Each message-driven bean, in processing the message, first does a lookup by primary key to see if the object associated with the key exists, and if it does not, it requests the entity's home object to create it. After that, they do further processing. The problem is that sometimes all the beans simultaneously get a message, resulting in each bean checking for the entity object at about the same time, and if they fail to find it (because none of them has created it yet), each creates an object, all with the same primary key. This is not caught until the beans start to complete their onMessage method, which I believe results in the container committing the transaction. One of the transactions will be committed successfully, while the other two will fail, get rolled back, and then be retried with the same message. The second time through, the other beans will find the entity object (since it has been created and committed) and they will complete correctly. In the end, they right thing occurs, except that there is a troubling exception or 2 in the log telling about the constraint violation (with the primary key) and the rollback. If it was just me, that would be fine, but our customer does not like to see exceptions in the log; that indicates to him that something is wrong.
    So, I am looking for someway to make sure that the actions of the message-driven beans are serialized. One suggestion from a colleague was to set the isolation level of the transactions being used by the container in processing the message-driven beans' onMessage method. However, the documentation does not mention any way to do this for a message-driven bean. Suggestions?
    Is the use of a UserTransaction a better way to do this? If I acquire a UserTransaction within the onMessage method of a message-driven bean, can I set its isolation level? How would this work? When I get a UserTransaction, does each client get a different transaction, or do they all get the same one?

    (1) The WebLogic JMS "unit-of-order" feature is a heavily adopted feature that was specifically designed to handle similar use cases - see the JMS developer guide for extensive documentation. In your use case, if "key" is used to define UOO, then there's no limit on the number of keys that can be processed concurrently, but messages for any particular key will be processed single-threaded in the order in which they were first submitted.
    Note that if you're using distributed destinations, the UOO feature is still fully supported - but the developer and/or administrator needs to decide whether to configure the destination to use "hash" or "path service" based routing (the JMS UOO edoc outlines the trade-offs).
    (2) Another alternative is to use a single MDB with max-beans-free-pool that processes all three types (as the other poster suggested). I think this assumes all MDBs run on the same JVM.
    (3) Another alternative is to use multiple queues, with a single MDB on each Q. Where some sort of hash algorithm is used to determine which Q is for the key. This approach is a "hand-coded" variant of the approach in (1) with "hash" based routing enabled...
    (4) If all MDBs actually do run in the same JVM, a third alternative is to use code the application to use a common lock to protect each key, eg, something like:
    // assume MyLock is simply a class with a "reference counter"
    // assume some global "staticHM" hash map that is all MDBs can access
    onMessage() {
    MyLock lock = null;
    key= msg.getKey();
    synchronized(staticHM) {
    lock = staticHM.get();
    if (lock = null) {
    lock = new lock();
    staticHM.put(key, new lock());
    lock.incRefCount();
    try {
    synchronized(lock) {
    // only one onMessage will be able to lock a particular key at a time
    do your work;
    } finally {
    synchronized(staticHT) {
    if (lock.defRefCount() == 0) staticHM.remove(lock);
    if (lock = null) staticHM.put(key);
    If multiple threads get a message with the same key, then only one thread at a time will work on the key.
    Hope this helps,
    Tom

  • Isolation Levels in ODI procedures

    Hi,
    I have a package with 1 interfaces and 2 procedures which I want to configure in as one transactional unit
    The package executes the following sequence
    1. Interface loads data from the source to target table
    2. Procedure updates a statuscode on the source table to S
    3. Procedure updates target table sequence number, but the procedure contains a where clause which filter records to updates
    based on records in the source table with statuscode = S.
    Step 3's execution is dependent on update in step 2. These steps behave as expected and all units tests pass when I
    leave the transaction porperty of the procedures as AutoCommit.
    However I want the interface and packages to be executed as a transcational unit so I configued them as follows.
    The 2 procedures are configured to execute in the same Transaction (Transaction 0) with Commit property as "No Commit".
    I based this on other forum entries.
    With this configuration my unit tests seem to fail, the 3 step does not result in any record being updated.
    I think the issue may be related to the isolation levels on the procedures, so I then configured the procedure's "Transaction Isolation" property to be "Read Uncommited".
    When I ran the test in ODI I got the following error below.
    Can you let me know if what I am trying to do is possible ?. Can you have a number of procedures in a single transactional unit,
    where uncommited changes carried out in the first procedure(not committed), can be read in subsequent steps within that same transactional unit.
    I am current using ODI Repository: Development_ODI_D8B4A_RC5
    Any feedback would be appreciated.
    Thanks,
    Breda
    ODI-1226: Step UPD REVN LSM fails after 1 attempt(s).
    ODI-1232: Procedure UPD REVN LSM execution fails.
    ODI-1228: Task UPD REVN LSM (Procedure) fails on the target ORACLE connection SALES_IMP_DATA_SERVER.
    Caused By: java.sql.SQLException: ODI-10068: SnpsConnection: Isolation level not supported
         at com.sunopsis.sql.SnpsConnection.setTransactionIsolation(SnpsConnection.java:905)
         at com.sunopsis.sql.SnpsConnection.changeIsolationLevel(SnpsConnection.java:329)
         at com.sunopsis.dwg.dbobj.SnpSession.changeIsolationLevel(SnpSession.java:3519)
         at com.sunopsis.dwg.dbobj.SnpSessTask.getDefaultDwgConnectConnection(SnpSessTask.java:518)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.getExecutor(SnpSessTaskSql.java:2936)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.processTask(SnpSessTaskSql.java:2878)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java:2602)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatAttachedTasks(SnpSessStep.java:546)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java:461)
         at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:1736)
         at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:1591)
         at oracle.odi.runtime.agent.processor.impl.StartScenRequestProcessor$2.doAction(StartScenRequestProcessor.java:568)
         at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:224)
         at oracle.odi.runtime.agent.processor.impl.StartScenRequestProcessor.doProcessStartScenTask(StartScenRequestProcessor.java:489)
         at oracle.odi.runtime.agent.processor.impl.StartScenRequestProcessor$StartScenTask.doExecute(StartScenRequestProcessor.java:1062)
         at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:118)
         at oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$1.run(DefaultAgentTaskExecutor.java:49)
         at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
         at oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor.executeAgentTask(DefaultAgentTaskExecutor.java:41)
         at oracle.odi.runtime.agent.processor.TaskExecutorAgentRequestProcessor.doExecuteAgentTask(TaskExecutorAgentRequestProcessor.java:94)
         at oracle.odi.runtime.agent.processor.TaskExecutorAgentRequestProcessor.process(TaskExecutorAgentRequestProcessor.java:85)
         at oracle.odi.runtime.agent.RuntimeAgent.startScenario(RuntimeAgent.java:700)
         at oracle.odi.runtime.agent.InternalRuntimeAgent.startScenario(InternalRuntimeAgent.java:52)
         at com.sunopsis.dwg.tools.StartScen.startScenOnLocalAgent(StartScen.java:983)
         at com.sunopsis.dwg.tools.StartScen.actionExecute(StartScen.java:245)
         at com.sunopsis.dwg.function.SnpsFunctionBaseRepositoryConnected.execute(SnpsFunctionBaseRepos
    Edited by: user807308 on 14-Jan-2011 01:04
    Edited by: user807308 on 14-Jan-2011 01:04

    Similar issue has been discussed here:
    Re: Transaction rollback...
    Check that out

  • Setting transaction isolation level on a replicated server stored procedure

    I have a SQL server that has replication turned onto to another server which is our reporting server. Replication is real-time (or close to it). On the report server I have a stored procedure that runs from a SRS report. My question is it possible or advisable
    or does it even make sense to set the "SET TRANSACTION ISOLATION LEVEL READ COMMITTED" on at the beginning of the stored procedure which selects data from the reporting server database? Is it possible for uncommitted data on the OLTP side of the
    house to be replicated before it is committed? We are having data issues with a report and have exhausted all options and was wondering if dirty data maybe the issue since the same parameters work for a report 1 sec and then next it doesnt.

    Only committed transactions are replicated to the subscriber.  But it is possible for the report to see dirty data if running in READ UNCOMMITTED or NOLOCK.  You should run your reports in READ COMMITTED or SNAPSHOT isolation , and your replication
    subscriber should be configured with READ COMMITTED SNAPSHOT ISLOATION eg
    alter database MySubscriber set allow_snapshot_isolation on;
    alter database MySubscriber set read_committed_snapshot on;
    as recommended here
    Enhance General Replication Performance.
    David
    David http://blogs.msdn.com/b/dbrowne/

  • Setting XA isolation level.

    Is there a configuration parameter that controls the default isolation level used by distributed transactions when you configure XA support on Oracle 8i? I know Oracle's default isolation level is READ COMMITTED, but I would like to have SERIALIZABLE as the isolation level for transactions that are initiated from some MS COM+ components accessing the database.
    Thanks,
    Sam

    Ian,
    The default for Oracle (any version) is ReadCommitted. The only other
    isolation level Oracle supports is Serializable but it's implemented in
    such a way that you will be allowed to continue until commit time and
    only then you might get an exception stating the the access for that
    transaction could not be serialized.
    I don't know for the jDriver but if you use the Oracle Thin XA driver
    even if you set the isolation level in your descriptor you will get an
    exception from Weblogic. It is a Weblogic bug and you can contact
    [email protected] to get a patch.
    Regards,
    Dejan
    IJ wrote:
    edocs (http://e-docs.bea.com/wls/docs70/oracle/trxjdbcx.html#1080746) states that,
    if using jDriver for Oracle/XA you can not set the transaction isolation level
    for a
    transaction and that 'Transactions use the transaction isolation level set on
    the connection
    or the default transaction isolation level for the database'. Does this mean that
    you shouldn't try to set it programatically (fair enough) or that you can't set
    it in the weblogic deployment descriptor either? Also anybody got any idea what
    the default is likely to be if you are using
    an Oracle 9iR2 database?

  • Setting the Isolation Level to Read Uncommitted

    Hello All,
    We are using BO XI r3 and SQL Server 2008. I would like to change the isolation level of the connection to read uncommitted. There are 2 options that i could by Googling..
    1. Making changes in the SBO file... this didnt work
    2. Making changes in the connectinit... even this didnt work
    i am not sure if there is anything else to done...  but i tried quering a table with a lock, the report got stuck so i am guessing that the settings didnt work

    Hi
    this is the only method for changing the transaction isolation level.
    Locate the path to your odbc.sbo file
    Click the connection in UDT and when server responds Click the Details button
    scroll down to the sbo line
    That is the file location of your sbo file (this will be the same on client and server)
    This change needs to be done, for client and servers both
    The isolation can only be set for the global connection.  Not per universe.
    Locate the file and make a backup before making any changes
    Find the Tag
    <DataBase Active="Yes" Name="MS SQL Server 2008">
    Below that tag should be a "Force SQLExecute" Parameter
    Like This
    <Parameter Name="Force SQLExecute">Procedures</Parameter>
    ADD this line
    <Parameter Name="Transaction Isolation Level">READ_UNCOMMITTED</Parameter>
    Save the odbc.sbo
    After client and server are changed
    Restart SIA
    Run the webi document again.
    Locations of the sbo file:
    R2: <Installation Directory>:\Program Files\Business Objects\BusinessObjects Enterprise 11.5\win32_x86\dataAccess\connectionServer\rdbms
    R3: <Installation Directory>:\Program Files\Business Objects\BusinessObjects Enterprise 12.0\win32_x86\dataAccess\connectionServer\rdbms
    BI4: <Installation Directory>:\Program Files (x86)\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\dataAccess\connectionServer\rdbms
    To make these changes effect, you have to restart ‘CMS server’, ‘the Connection Servers’, ‘Webi Report Server’ from ‘Central Configuration Manager’ (CCM).
    Information is available in the Data Access guide
    Jacqueline

  • Setting db isolation level on transaction without EJB

              I'm using UserTransaction in the servlet container, to control XA transactions.
              We're not using EJB. How do I set the database isolation level? I'm tempted
              to use java.sql.Connection.setTransactionIsolation(). However, the Sun Javadoc
              for that method says you can't call that after the transaction has started (which
              makes sense). Right now, we're starting the transaction, getting a connection,
              closing the connection, and committing the transaction. I guess that order won't
              work if I want to set the isolation level. Or am I mixing apples and oranges
              here? If I use UserTransaction, is it even appropriate to try to set the isolation
              level on the connection?
              All I really want to do is change the default isolation level. We do not need
              different isolation levels for different use cases. (Not yet, anyway.) We might
              have transactions against two different database instances or other resource managers.
              That's why I want to use UserTransaction and XA transactions.
              Thanks!
              Steve Molitor
              [email protected]
              

    Only committed transactions are replicated to the subscriber.  But it is possible for the report to see dirty data if running in READ UNCOMMITTED or NOLOCK.  You should run your reports in READ COMMITTED or SNAPSHOT isolation , and your replication
    subscriber should be configured with READ COMMITTED SNAPSHOT ISLOATION eg
    alter database MySubscriber set allow_snapshot_isolation on;
    alter database MySubscriber set read_committed_snapshot on;
    as recommended here
    Enhance General Replication Performance.
    David
    David http://blogs.msdn.com/b/dbrowne/

  • Setting transaction isolation level rises ORA-02089 error

    Hello
    We have configured a distributed transaction in our application server and
    we are using openjpa 1.2.1 and Glassfish application server and Oracle 11g as DB server. Although the default behavior of transaction locking must be optimistic,
    it seems that pessimistic locking has been happened.
    It is found that Row Lock contention happens in a specific table.
    This is the exception :
    java.sql.SQLException: ORA-02049: timeout: distributed transaction waiting for lock
    Already all the following properties have been set for openjpa.
    1. <persistence-unit name="JPXA" transation-type="JTA">
    2. <property name="openjpa.TransactionMode" value="managed"/>
    You can try a plug-in string to lookup the TM in JNDI (the value is the JNDI name of GlassFish TM as per Google search)
    3. <property name="openjpa.ManagedRuntime"
    value="jndi(TransactionManagerName=java:appserver/TransactionManager)"/>
    Following searching about this locking problem, we found that we should add two more properties for openjpa as listed below.
    <property name="openjpa.LockManager" value="version" />
    <property name="openjpa.jdbc.TransactionIsolation" value="read-committed" />
    but this time by setting the transaction isolation level, we have got another error: org.apache.openjpa.persistence.PersistenceException: ORA-02089: COMMIT is not allowed in a subordinate session.
    Thanks for any help.
    Regards,
    Sargol

    Hello
    We have configured a distributed transaction in our application server and
    we are using openjpa 1.2.1 and Glassfish application server and Oracle 11g as DB server. Although the default behavior of transaction locking must be optimistic,
    it seems that pessimistic locking has been happened.
    It is found that Row Lock contention happens in a specific table.
    This is the exception :
    java.sql.SQLException: ORA-02049: timeout: distributed transaction waiting for lock
    Already all the following properties have been set for openjpa.
    1. <persistence-unit name="JPXA" transation-type="JTA">
    2. <property name="openjpa.TransactionMode" value="managed"/>
    You can try a plug-in string to lookup the TM in JNDI (the value is the JNDI name of GlassFish TM as per Google search)
    3. <property name="openjpa.ManagedRuntime"
    value="jndi(TransactionManagerName=java:appserver/TransactionManager)"/>
    Following searching about this locking problem, we found that we should add two more properties for openjpa as listed below.
    <property name="openjpa.LockManager" value="version" />
    <property name="openjpa.jdbc.TransactionIsolation" value="read-committed" />
    but this time by setting the transaction isolation level, we have got another error: org.apache.openjpa.persistence.PersistenceException: ORA-02089: COMMIT is not allowed in a subordinate session.
    Thanks for any help.
    Regards,
    Sargol

  • How to change the transaction isolation level of a CMP?

    How to change the transaction isolation level of a CMP from SUN's Deployment Tool? So far I can't find any entry for this setting.

    Anuradha W wrote:
    That means, currently the only way tospecify the transaction level is through
    weblogic-ejb-jar.xml deployment descriptor?
    for WLS-generated code, yes.Somewhat related to this question, we have written a standalone testcase to reproduce this issue we have been having. Basically, the issue is that even though we configure the isolation level to a non-default one in the deployment descriptor, the connections returned by the datasource seem to be having the default (which is Read Committed). The DBMS is DB2.
    weblogic-ejb-jar.xml has the following set:
    <isolation-level>TransactionRepeatableRead</isolation-level>
    And we printed the isolation level of the connection returned from a method in the EJB, but the isolation level is still the default. I can share the code to reproduce the problem if you want to take a look at it. Please let me know how I can get that across to you.
    Thanks,
    AnuradhaIf you are using our JDBC driver for DB2, or can switch to it,
    just for a test, there is some debug I'd like from you.
    Joe

  • How to Set the Transaction Isolation Level in WebLogic?

    Is there a way to set the transaction isolation level in WebLogic 9.2 or WebLogic 10?
    For an example say, we have an application which is supported for several database platforms. Without setting the transaction isolation level in DBMS level, is there a way to specify this in WebLogic to make it common for all the DBMS type?
    And I found a way to change the transaction isolation level in WebSphere application server using a property called webSphereDefaultIsolationLevel.
    [url http://www-1.ibm.com/support/docview.wss?rs=180&uid=swg21224492]http://www-1.ibm.com/support/docview.wss?rs=180&uid=swg21224492
    Is there a way to do the same thing in WebLogic application server 9.2 or 10?

    Anuradha W wrote:
    That means, currently the only way tospecify the transaction level is through
    weblogic-ejb-jar.xml deployment descriptor?
    for WLS-generated code, yes.Somewhat related to this question, we have written a standalone testcase to reproduce this issue we have been having. Basically, the issue is that even though we configure the isolation level to a non-default one in the deployment descriptor, the connections returned by the datasource seem to be having the default (which is Read Committed). The DBMS is DB2.
    weblogic-ejb-jar.xml has the following set:
    <isolation-level>TransactionRepeatableRead</isolation-level>
    And we printed the isolation level of the connection returned from a method in the EJB, but the isolation level is still the default. I can share the code to reproduce the problem if you want to take a look at it. Please let me know how I can get that across to you.
    Thanks,
    AnuradhaIf you are using our JDBC driver for DB2, or can switch to it,
    just for a test, there is some debug I'd like from you.
    Joe

  • EJB Isolation levels in ejb-j2ee-engine.xml

    Can anyone explain to me why I only seem to have the option of using the 'repeatable read' isolation level in Netweaver Developer Studio?
    I'm new to SAP and Netweaver but as a seasoned J2EE developer I would have expected to find read committed, read uncommitted, serializable, as well as repeatable read.
    Is there some SAP or Netweaver specific reason why I don't get to choose these options, or do I need to enable them by configuring properties somewhere?

    Hi Steve,
    The reason is that the J2EE Engine EJB Container supports Read Committed and Repeatable Read isolation levels and Read Committed is the default one. That's why you only have the option of specifying Repeatable Read.
    For more information on locking and isolation levels please have a look at these documents:
    http://help.sap.com/saphelp_nw04/helpdata/en/37/019b3e25f95f14e10000000a114084/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/a1/d81db94a10bc4b83b3f60b0e3037e7/frameset.htm
    Best regards,
    Vladimir

  • Isolation level "read uncommitted"

    Hi,
    How to configure the isolation level of an environment to read uncommitted?
    Thanks
    Andy

    Andy,
    There is no per-Environment setting for the isolation level. This has to be specified for each Transaction (using TransactionConfig), Cusor (with CursorConfig) or method (with LockMode).
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Restore default isolation level fails with connection in pool

    Hi,
    I am developing an application that needs to set the TransactionIsolation to SERIALIZE for a transaction. Setting the TransactionIsolation is not the problem. After this transaction is committed or rolled back, i set the isolation level back to the default i saved before.
    The code gets executed and throws no exception. The connection i used is released into the pool. The next time i get this connection from the pool the isolation level is already SERIALIZE. This is not what i wanted to achieve.
    It has to be possible to change the isolation level for transaction, isn´t it?
    Here is the code, that i use. The ConnectionManager gets the connection from a connection pool i configured in the jdbc connector service. Excep for this issue any other operation works fine.
                    ConnectionManager connectionManager = new ConnectionManager();
              Connection con = null;
              int transactionIsolationLevel = 0;
              Queue queue = null;
              List list = null;
              try {
                   con = connectionManager.getConnection();
                   transactionIsolationLevel = con.getTransactionIsolation();
                   if( logger.isInfoEnabled())
                        logger.info(LOGLOC + "ISOLATION_LEVEL default: " + transactionIsolationLevel);
                   // auskommentiert für RE
                   con.setTransactionIsolation( Connection.TRANSACTION_SERIALIZABLE );
                   con.setAutoCommit( false );
              QueueManager queueManager = new QueueManager();
              list = queueManager.GetQueueEntriesBySizeGroups( con, small, medium, large, serverNode );
              con.commit();
              } catch (ClassNotFoundException cnfe) {
                   logger.error(LOGLOC + "Exception setting up transaction context for queue service!", cnfe);
                   handleExceptions(queue, cnfe);
                   try {
                        con.rollback();
                   } catch (SQLException e) {
                        logger.error(LOGLOC + "Exception rolling back transaction!", e);               
              } catch (SQLException sqle) {
                   logger.error(LOGLOC + "Exception setting up transaction context for queue service!", sqle);
                   handleExceptions(queue, sqle);
                   try {
                        con.rollback();
                   } catch (SQLException e) {
                        logger.error(LOGLOC + "Exception rolling back transaction!", e);               
              } catch (QueueManagerException qme) {
                   logger.error(LOGLOC + "Exception executing queue manager!", qme);
                   handleExceptions(queue, qme);
                   try {
                        con.rollback();
                   } catch (SQLException e) {
                        logger.error(LOGLOC + "Exception rolling back transaction!", e);               
              } finally {
                   try {
                        con.setAutoCommit(true);
                        if( logger.isInfoEnabled())
                             logger.info(LOGLOC + "ISOLATION_LEVEL before setting default: " + con.getTransactionIsolation() + " now setting: " + transactionIsolationLevel );
                        // Auskommentiert für RE
                        con.setTransactionIsolation( transactionIsolationLevel );
                        con.close();
                   } catch (SQLException e) {
                        logger.error(LOGLOC + "Exception setting up transaction context for queue service!", e);               
    The datasource is a simple jdbc1.x Oracle Datasource with no special settings.
    In a remote debugging session i saw, that the wrapped Connection from the datasource sets the txLevel successfully, But the underlying T4Connection does not get this isolation level. Could this be a bug?
    Any hints, solutions?

    Hi,
    I am developing an application that needs to set the TransactionIsolation to SERIALIZE for a transaction. Setting the TransactionIsolation is not the problem. After this transaction is committed or rolled back, i set the isolation level back to the default i saved before.
    The code gets executed and throws no exception. The connection i used is released into the pool. The next time i get this connection from the pool the isolation level is already SERIALIZE. This is not what i wanted to achieve.
    It has to be possible to change the isolation level for transaction, isn´t it?
    Here is the code, that i use. The ConnectionManager gets the connection from a connection pool i configured in the jdbc connector service. Excep for this issue any other operation works fine.
                    ConnectionManager connectionManager = new ConnectionManager();
              Connection con = null;
              int transactionIsolationLevel = 0;
              Queue queue = null;
              List list = null;
              try {
                   con = connectionManager.getConnection();
                   transactionIsolationLevel = con.getTransactionIsolation();
                   if( logger.isInfoEnabled())
                        logger.info(LOGLOC + "ISOLATION_LEVEL default: " + transactionIsolationLevel);
                   // auskommentiert für RE
                   con.setTransactionIsolation( Connection.TRANSACTION_SERIALIZABLE );
                   con.setAutoCommit( false );
              QueueManager queueManager = new QueueManager();
              list = queueManager.GetQueueEntriesBySizeGroups( con, small, medium, large, serverNode );
              con.commit();
              } catch (ClassNotFoundException cnfe) {
                   logger.error(LOGLOC + "Exception setting up transaction context for queue service!", cnfe);
                   handleExceptions(queue, cnfe);
                   try {
                        con.rollback();
                   } catch (SQLException e) {
                        logger.error(LOGLOC + "Exception rolling back transaction!", e);               
              } catch (SQLException sqle) {
                   logger.error(LOGLOC + "Exception setting up transaction context for queue service!", sqle);
                   handleExceptions(queue, sqle);
                   try {
                        con.rollback();
                   } catch (SQLException e) {
                        logger.error(LOGLOC + "Exception rolling back transaction!", e);               
              } catch (QueueManagerException qme) {
                   logger.error(LOGLOC + "Exception executing queue manager!", qme);
                   handleExceptions(queue, qme);
                   try {
                        con.rollback();
                   } catch (SQLException e) {
                        logger.error(LOGLOC + "Exception rolling back transaction!", e);               
              } finally {
                   try {
                        con.setAutoCommit(true);
                        if( logger.isInfoEnabled())
                             logger.info(LOGLOC + "ISOLATION_LEVEL before setting default: " + con.getTransactionIsolation() + " now setting: " + transactionIsolationLevel );
                        // Auskommentiert für RE
                        con.setTransactionIsolation( transactionIsolationLevel );
                        con.close();
                   } catch (SQLException e) {
                        logger.error(LOGLOC + "Exception setting up transaction context for queue service!", e);               
    The datasource is a simple jdbc1.x Oracle Datasource with no special settings.
    In a remote debugging session i saw, that the wrapped Connection from the datasource sets the txLevel successfully, But the underlying T4Connection does not get this isolation level. Could this be a bug?
    Any hints, solutions?

  • Setting isolation level to 2.

    Hi All,
    I'm trying to use Isolation level 2 for "read committed" isolation.
    all I can find is how to set level 3 isolation (by calling setTxnSerializableIsolation(true)).
    Thanks for your help.
    ~aviron

    Hi Aviron,
    The isolation degrees are discussed in the TXN GSG guide here (chapter 4. Concurrency, Isolation):
    http://www.oracle.com/technology/documentation/berkeley-db/je/TransactionGettingStarted/BerkeleyDB-JE-Txn.pdf
    For configuring committed reads (degree 2 isolation), you can do one of the following:
    - create your transaction (txn) so that it allows committed reads, by specifying true for the TransactionConfig.setReadCommitted() call;
    - specify true on the CursorConfig.setReadCommitted() call;
    - specify LockMode.READ_COMMITTED to configure degree 2 isolation on a read-by-read basis.
    Regards,
    Andrei

  • CF10 Datasources and Isolation Level

    I've been looking all over for a solution to this and have been unable to find one.  In CF9 using jrun, we are able to set the default isolation level on a datasource so that any time it is used it defaults to dirty read in case a record is in a lock state it still returns the current data.  However in CF10 with it using Tomcat, I cannot find anyway to even configure a datasource through Tomcat, or set the default isolation level on a datasource created in the CF10 administration panel.  I know we could surround every single query with a <cftransaction> tag that sets the isolation level, but that is unrealistic as this is a very large web service with thousands of queries.
    Can anyone help out with this?  Thanks!

    Hello
    You should be able to see your inserted row in the same session
    Session 1:_
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    SQL> SELECT *  FROM demo;
            ID
            11
             1
             2
             3
             4
             5
             8
             9
            10
    9 rows selected.
    SQL>
    SQL> INSERT INTO demo  VALUES (11);
    1 row created.
    SQL>
    SQL> SELECT *   FROM demo;
            ID
            11
             1
             2
             3
             4
             5
             8
             9
            10
            11
    10 rows selected.
    Session 2: Different session without committing the result from the above session_
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
    SQL> select * from demo;
            ID
            11
             1
             2
             3
             4
             5
             8
             9
            10
    9 rows selected.Regards
    Edited by: OrionNet on Jan 4, 2009 9:58 PM

Maybe you are looking for