ORA-08177: can't serialize access for this transaction

前端 未结 1 1478
一生所求
一生所求 2020-12-17 10:13

I have a very simple code using ADO.NET which throws ORA-08177 exception. I am not sure what\'s wrong with this. I am trying this on a windows vista machine which has oracle

相关标签:
1条回答
  • 2020-12-17 10:51

    You are using a serializable transaction which waits for some other transaction locking the same table to ROLLBACK.

    If this other transaction does not rollback but commits instead, you will get this error.

    The scenario seems to be as following:

    1. Alice opens her browser session which calls DELETE FROM TABLE1 WHERE Version = 'v1'

      • Bob opens his session which calls DELETE FROM TABLE1 WHERE Version = 'v1' after Alice did it but before she commited.

      Bob's transaction waits since Alice locked the rows with Version = 'v1'

      • Alice commits her transaction

      • Bob's transaction fails with Cannot serialize access

    To work around this, set TRANSACTION ISOLATION LEVEL to READ COMMITTED:

    transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted)
    

    In this case, Bob's query will be reissued after Alice commits her changes, as if Bob's transaction were started after Alice's one was committed.

    Update

    Could you please post a trace of your connection?

    To do this, issue this command right after connecting:

    (New OracleCommand("ALTER SESSION SET SQL_TRACE=TRUE", connection, transaction)).ExecuteNonQuery();
    

    , then look in $ORACLE_HOME\admin\udump for a fresh *.trc file

    0 讨论(0)
提交回复
热议问题