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;
        }
    }

  • 相关阅读:
    [转] Windows Server 2012 Beta Cluster (HyperV 3.0)SMB篇
    [转] 使用效能監視器收集HyperV的效能,並透過PAL Tool產出報表
    [转]Windows Server 8 Beta 介绍 (04) –Windows PowerShell Web Access简介 (下)
    [转]SSL 与 数字证书 的基本概念和工作原理
    [转] HyperV如何避免NUMA對效能上的影響
    [转] Windows Server “8” Beta 介绍 (06) –基于策略的IP地址分配(中)
    [转]SCVMM2012部署之四:安装VMM远程控制台
    [转] SCVMM2012部署之二:安装VMM服务器和VMM控制台
    [转]Windows Server 2012 RC 之 HyperV 3.0 PowerShell 命令详解 (01)
    [转] Windows Server “8” Beta 介绍 (07) –基于策略的IP地址分配(下)
  • 原文地址:https://www.cnblogs.com/hubo0831/p/3368508.html
Copyright © 2011-2022 走看看