Задайте вопросЗадайте вопрос
 

ВопросMS Oracle provider - transaction bug

  • 1 сентября 2008 г. 15:01Josip Bakić Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
    Hello!

    We're using the MS provider for Oracle to access the database in our app (System.Data.OracleClient.dll file version: 2.0.50727.3053 (netfxsp.050727-3000)), and since the recent Framework Service Pack that we installed a week or two ago, we've started to experience some strange behavior regarding transactions. Namely, we start a Serializable isolation level transaction, yet anything we do inside it is immediately commited into the DB (we can see it through the Oracle SQL Developer while stepping through our code), and in case of an exception, even though the transaction is neatly rolled back in the code, evrything that got in still stays in the DB. In short, transactions do not work.

    After a lengthy struggle trying to discover who to blame, I'm sorry to report, we've determined it's the MS provider for Oracle. For some strange reason the connection's internal "TransactionState" flag changes from "LocalStarted" to "AutoCommit". Curiously, this does not happen the first time you open a transaction - if you wish to recreate this, you have to start and commit a dummy transaction, inside of which you need not do anything to the data in the DB, and then open a new connection and start a second transaction on it - using the debugger you can see that in the second pass the flag state has changed and the erroneous behavior appears.

    We've also discovered that adding this line after starting a transaction makes everything work just fine:

    connection.GetType().GetProperty("TransactionState", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(connection, 1, null);

    (my apologies, I didn't succeed in marking the code block)

    So, just manually forcing the flag back to LocalStarted is enough to fix it.

    I hope this post will find it's way to the right place, and the people involved will have enough to go on to fix this as soon as possible, since, IMO, this is beyond critical.

    Josip Bakić

Все ответы