InDoubt() публичный Метод

public InDoubt ( ) : void
Результат void
Пример #1
0
        void ISinglePhaseNotificationInternal.SinglePhaseCommit(IPromotedEnlistment singlePhaseEnlistment)
        {
            bool spcCommitted = false;

            _promotedEnlistment = singlePhaseEnlistment;
            try
            {
                _singlePhaseNotifications.SinglePhaseCommit(SinglePhaseEnlistment);
                spcCommitted = true;
            }
            finally
            {
                if (!spcCommitted)
                {
                    SinglePhaseEnlistment.InDoubt();
                }
            }
        }
Пример #2
0
		/// <summary>
		/// Rollbacks the specified single phase enlistment.
		/// </summary>
		/// <param name="singlePhaseEnlistment">The single phase enlistment.</param>
		public void Rollback(SinglePhaseEnlistment singlePhaseEnlistment)
		{
			onTxComplete();
			try
			{
				session.Rollback(PromotableRavenClientEnlistment.GetLocalOrDistributedTransactionId(transaction));

				using (var machineStoreForApplication = IsolatedStorageFile.GetMachineStoreForDomain())
				{
					machineStoreForApplication.DeleteFile(TransactionRecoveryInformationFileName);
				}
			}
			catch (Exception e)
			{
				logger.ErrorException("Could not rollback distributed transaction", e);
				singlePhaseEnlistment.InDoubt(e);
				return;
			}
			singlePhaseEnlistment.Aborted();
		}
        // Called by the transaction to initiate commit sequence
        public void SinglePhaseCommit(SysTx.SinglePhaseEnlistment enlistment)
        {
            Debug.Assert(null != enlistment, "null enlistment?");

            SqlInternalConnection connection      = GetValidConnection();
            SqlConnection         usersConnection = connection.Connection;

            Bid.Trace("<sc.SqlDelegatedTransaction.SinglePhaseCommit|RES|CPOOL> %d#, Connection %d#, committing transaction.\n", ObjectID, connection.ObjectID);

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
#if DEBUG
                TdsParser.ReliabilitySection tdsReliabilitySection = new TdsParser.ReliabilitySection();

                RuntimeHelpers.PrepareConstrainedRegions();
                try {
                    tdsReliabilitySection.Start();
#else
                {
#endif //DEBUG
                    // If the connection is dooomed, we can be certain that the
                    // transaction will eventually be rolled back, and we shouldn't
                    // attempt to commit it.
                    if (connection.IsConnectionDoomed)
                    {
                        lock (connection)
                        {
                            _active     = false; // set to inactive first, doesn't matter how the rest completes, this transaction is done.
                            _connection = null;
                        }

                        enlistment.Aborted(SQL.ConnectionDoomed());
                    }
                    else
                    {
                        Exception commitException;
                        lock (connection)
                        {
                            try
                            {
                                // Now that we've acquired the lock, make sure we still have valid state for this operation.
                                ValidateActiveOnConnection(connection);

                                _active     = false; // set to inactive first, doesn't matter how the rest completes, this transaction is done.
                                _connection = null;  // Set prior to ExecuteTransaction call in case this initiates a TransactionEnd event

                                connection.ExecuteTransaction(SqlInternalConnection.TransactionRequest.Commit, null, IsolationLevel.Unspecified, _internalTransaction, true);
                                commitException = null;
                            }
                            catch (SqlException e)
                            {
                                commitException = e;

                                ADP.TraceExceptionWithoutRethrow(e);

                                // Doom the connection, to make sure that the transaction is
                                // eventually rolled back.
                                // VSTS 144562: doom the connection while having the lock on it to prevent race condition with "Transaction Ended" Event
                                connection.DoomThisConnection();
                            }
                            catch (InvalidOperationException e)
                            {
                                commitException = e;
                                ADP.TraceExceptionWithoutRethrow(e);
                                connection.DoomThisConnection();
                            }
                        }
                        if (commitException != null)
                        {
                            // connection.ExecuteTransaction failed with exception
                            if (_internalTransaction.IsCommitted)
                            {
                                // Even though we got an exception, the transaction
                                // was committed by the server.
                                enlistment.Committed();
                            }
                            else if (_internalTransaction.IsAborted)
                            {
                                // The transaction was aborted, report that to
                                // SysTx.
                                enlistment.Aborted(commitException);
                            }
                            else
                            {
                                // The transaction is still active, we cannot
                                // know the state of the transaction.
                                enlistment.InDoubt(commitException);
                            }

                            // We eat the exception.  This is called on the SysTx
                            // thread, not the applications thread.  If we don't
                            // eat the exception an UnhandledException will occur,
                            // causing the process to FailFast.
                        }

                        connection.CleanupConnectionOnTransactionCompletion(_atomicTransaction);
                        if (commitException == null)
                        {
                            // connection.ExecuteTransaction succeeded
                            enlistment.Committed();
                        }
                    }
                }
#if DEBUG
                finally {
                    tdsReliabilitySection.Stop();
                }
#endif //DEBUG
            }
            catch (System.OutOfMemoryException e)
            {
                usersConnection.Abort(e);
                throw;
            }
            catch (System.StackOverflowException e)
            {
                usersConnection.Abort(e);
                throw;
            }
            catch (System.Threading.ThreadAbortException e)
            {
                usersConnection.Abort(e);
                throw;
            }
        }
Пример #4
0
		/// <summary>
		/// Rollbacks the specified single phase enlistment.
		/// </summary>
		/// <param name="singlePhaseEnlistment">The single phase enlistment.</param>
		public void Rollback(SinglePhaseEnlistment singlePhaseEnlistment)
		{
			onTxComplete();
			try
			{
				session.Rollback(PromotableRavenClientEnlistment.GetLocalOrDistributedTransactionId(transaction));

				DeleteFile();
			}
			catch (Exception e)
			{
				logger.ErrorException("Could not rollback distributed transaction", e);
				singlePhaseEnlistment.InDoubt(e);
				return;
			}
			singlePhaseEnlistment.Aborted();
		}
Пример #5
0
		/// <summary>
		/// Rollbacks the specified single phase enlistment.
		/// </summary>
		/// <param name="singlePhaseEnlistment">The single phase enlistment.</param>
		public void Rollback(SinglePhaseEnlistment singlePhaseEnlistment)
		{
			onTxComplete();
			try
			{
                session.Rollback(transaction.LocalIdentifier);

				DeleteFile();
			}
			catch (Exception e)
			{
				logger.ErrorException("Could not rollback distributed transaction", e);
				singlePhaseEnlistment.InDoubt(e);
				return;
			}
			singlePhaseEnlistment.Aborted();
			ctx.Dispose();
		}
 public void SinglePhaseCommit(SinglePhaseEnlistment enlistment)
 {
     SqlInternalConnection validConnection = this.GetValidConnection();
     SqlConnection connection = validConnection.Connection;
     Bid.Trace("<sc.SqlDelegatedTransaction.SinglePhaseCommit|RES|CPOOL> %d#, Connection %d#, committing transaction.\n", this.ObjectID, validConnection.ObjectID);
     RuntimeHelpers.PrepareConstrainedRegions();
     try
     {
         if (validConnection.IsConnectionDoomed)
         {
             lock (validConnection)
             {
                 this._active = false;
                 this._connection = null;
             }
             enlistment.Aborted(SQL.ConnectionDoomed());
         }
         else
         {
             Exception exception;
             lock (validConnection)
             {
                 try
                 {
                     this.ValidateActiveOnConnection(validConnection);
                     this._active = false;
                     this._connection = null;
                     validConnection.ExecuteTransaction(SqlInternalConnection.TransactionRequest.Commit, null, System.Data.IsolationLevel.Unspecified, this._internalTransaction, true);
                     exception = null;
                 }
                 catch (SqlException exception3)
                 {
                     exception = exception3;
                     ADP.TraceExceptionWithoutRethrow(exception3);
                     validConnection.DoomThisConnection();
                 }
                 catch (InvalidOperationException exception2)
                 {
                     exception = exception2;
                     ADP.TraceExceptionWithoutRethrow(exception2);
                     validConnection.DoomThisConnection();
                 }
             }
             if (exception != null)
             {
                 if (this._internalTransaction.IsCommitted)
                 {
                     enlistment.Committed();
                 }
                 else if (this._internalTransaction.IsAborted)
                 {
                     enlistment.Aborted(exception);
                 }
                 else
                 {
                     enlistment.InDoubt(exception);
                 }
             }
             validConnection.CleanupConnectionOnTransactionCompletion(this._atomicTransaction);
             if (exception == null)
             {
                 enlistment.Committed();
             }
         }
     }
     catch (OutOfMemoryException exception6)
     {
         connection.Abort(exception6);
         throw;
     }
     catch (StackOverflowException exception5)
     {
         connection.Abort(exception5);
         throw;
     }
     catch (ThreadAbortException exception4)
     {
         connection.Abort(exception4);
         throw;
     }
 }