zoukankan      html  css  js  c++  java
  • 为什么SqlTransaction.Rollback会抛出SqlException(11,-2)(即SQL超时异常)

    // System.Data.SqlClient.SqlTransaction
    public override void Rollback()
    {
        if (this.IsYukonPartialZombie)
        {
            if (Bid.AdvancedOn)
            {
                Bid.Trace("<sc.SqlTransaction.Rollback|ADV> %d# partial zombie no rollback required "this.ObjectID);
            }
            this._internalTransaction = null;
            return;
        }
        this.ZombieCheck();
        SqlStatistics statistics = null;
        IntPtr intPtr;
        Bid.ScopeEnter(out intPtr, "<sc.SqlTransaction.Rollback|API> %d#"this.ObjectID);
        SNIHandle target = null;
        RuntimeHelpers.PrepareConstrainedRegions();
        try
        {
            target = SqlInternalConnection.GetBestEffortCleanupTarget(this._connection);
            statistics = SqlStatistics.StartTimer(this.Statistics);
            this._isFromAPI = true;
            this._internalTransaction.Rollback();
        }
        catch (OutOfMemoryException e)
        {
            this._connection.Abort(e);
            throw;
        }
        catch (StackOverflowException e2)
        {
            this._connection.Abort(e2);
            throw;
        }
        catch (ThreadAbortException e3)
        {
            this._connection.Abort(e3);
            SqlInternalConnection.BestEffortCleanup(target);
            throw;
        }
        finally
        {
            this._isFromAPI = false;
            SqlStatistics.StopTimer(statistics);
            Bid.ScopeLeave(ref intPtr);
        }
    }

    // System.Data.SqlClient.SqlInternalTransaction
    internal void Rollback()
    {
        IntPtr intPtr;
        Bid.ScopeEnter(out intPtr, "<sc.SqlInternalTransaction.Rollback|API> %d#"this.ObjectID);
        if (this._innerConnection.IsLockedForBulkCopy)
        {
            throw SQL.ConnectionLockedForBcpEvent();
        }
        this._innerConnection.ValidateConnectionForExecute(null);
        try
        {
            this._innerConnection.ExecuteTransaction(SqlInternalConnection.TransactionRequest.IfRollback, null, IsolationLevel.Unspecified, nullfalse);
            this.Zombie();
        }
        catch (Exception e)
        {
            if (!ADP.IsCatchableExceptionType(e))
            {
                throw;
            }
            this.CheckTransactionLevelAndZombie();
            if (!this._disposing)
            {
                throw;
            }
        }
        finally
        {
            Bid.ScopeLeave(ref intPtr);
        }
    }

    // System.Data.SqlClient.SqlInternalConnectionTds
    internal override void ExecuteTransaction(SqlInternalConnection.TransactionRequest transactionRequest, string name, IsolationLevel iso, SqlInternalTransaction internalTransaction, bool isDelegateControlRequest)
    {
        if (base.IsConnectionDoomed)
        {
            if (transactionRequest == SqlInternalConnection.TransactionRequest.Rollback || transactionRequest == SqlInternalConnection.TransactionRequest.IfRollback)
            {
                return;
            }
            throw SQL.ConnectionDoomed();
        }
        else
        {
            if ((transactionRequest == SqlInternalConnection.TransactionRequest.Commit || transactionRequest == SqlInternalConnection.TransactionRequest.Rollback || transactionRequest == SqlInternalConnection.TransactionRequest.IfRollback) && !this.Parser.MARSOn && this.Parser._physicalStateObj.BcpLock)
            {
                throw SQL.ConnectionLockedForBcpEvent();
            }
            string transactionName = (name == null) ? string.Empty : name;
            if (!this._parser.IsYukonOrNewer)
            {
                this.ExecuteTransactionPreYukon(transactionRequest, transactionName, iso, internalTransaction);
                return;
            }
            this.ExecuteTransactionYukon(transactionRequest, transactionName, iso, internalTransaction, isDelegateControlRequest);
            return;
        }
    }

  • 相关阅读:
    Redis的发布订阅
    Redis的事物
    Redis的持久化
    Redis配置文件详解
    Redis五大数据类型
    Redis安装
    DP练习题回顾
    基环树浅谈
    Tarjan算法浅谈
    拓展欧拉定理浅谈
  • 原文地址:https://www.cnblogs.com/hubo0831/p/3368508.html
Copyright © 2011-2022 走看看