Aborted() public method

public Aborted ( ) : void
return void
 public void Rollback(SinglePhaseEnlistment en)
 {
     if (en == null)
     {
         throw new ArgumentNullException("en");
     }
     try
     {
         this.handle.WaitOne();
     }
     catch (ObjectDisposedException)
     {
     }
     lock (this.syncRoot)
     {
         if (this.transaction != null)
         {
             this.transaction.Dispose();
         }
         if ((this.connection != null) && (this.connection.State != ConnectionState.Closed))
         {
             this.connection.Close();
             this.connection = null;
         }
         en.Aborted();
     }
 }
		void IPromotableSinglePhaseNotification.Rollback( SinglePhaseEnlistment singlePhaseEnlistment ) {
			this.simpleTransaction.Rollback();
			singlePhaseEnlistment.Aborted();
			DriverTransactionManager.RemoveDriverInTransaction( this.baseTransaction );
			this.connection.driver.CurrentTransaction = null;
			if( this.connection.State == ConnectionState.Closed ) {
				this.connection.CloseFully();
			}
		}
 public void SinglePhaseCommit(SinglePhaseEnlistment singlePhaseEnlistment)
 {
     try
     {
         Neo4jTransaction.DoCommit(_transactionExecutionEnvironment);
         singlePhaseEnlistment.Committed();
     }
     finally
     {
         singlePhaseEnlistment.Aborted();
     }
 }
Esempio n. 4
0
    public void Rollback(SinglePhaseEnlistment singlePhaseEnlistment)
    {
      // prevent commands in main thread to run concurrently
      Driver driver = connection.driver;
      lock (driver)
      {
        rollbackThreadId = Thread.CurrentThread.ManagedThreadId;
        while (connection.Reader != null)
        {
          // wait for reader to finish. Maybe we should not wait 
          // forever and cancel it after some time?
          System.Threading.Thread.Sleep(100);
        }
        simpleTransaction.Rollback();
        singlePhaseEnlistment.Aborted();
        DriverTransactionManager.RemoveDriverInTransaction(baseTransaction);

        if (connection.State == ConnectionState.Closed)
          connection.CloseFully();
        rollbackThreadId = 0;
      }
    }
Esempio n. 5
0
 ///<summary>
 /// Attempt to commit the internal transaction.
 ///</summary>
 void IPromotableSinglePhaseNotification.SinglePhaseCommit(SinglePhaseEnlistment singlePhaseEnlistment)
 {
     try
     {
         // attempt to commit the enlistment
         this.dbTransaction.Commit();
         singlePhaseEnlistment.Committed();
     }
     catch (Exception e)
     {
         // something went wrong, make sure the transaction aborts
         singlePhaseEnlistment.Aborted(e);
         throw;
     }
     finally
     {
         // clean-up our resources
         Dispose();
     }
 }
        /// <summary>
        /// Notifies this object that the transaction is being rolled back.
        /// </summary>
        /// <param name="singlePhaseEnlistment">
        /// Interfacet used to send a response to  the transaction manager.
        /// </param>
        void IPromotableSinglePhaseNotification.Rollback(SinglePhaseEnlistment singlePhaseEnlistment)
        {
            m_dbTransaction.Rollback();
            singlePhaseEnlistment.Aborted();
            m_dbConnection.Enlistment = null;

            if (m_disposeConnection)
            {
                m_dbConnection.Dispose();
            }
        }
        public void Rollback(SinglePhaseEnlistment singlePhaseEnlistment)
        {
			session.Rollback(PromotableRavenClientEnlistment.GetLocalOrDistributedTransactionId(transaction));
            singlePhaseEnlistment.Aborted();
        }
Esempio n. 8
0
		public void SinglePhaseCommit(SinglePhaseEnlistment singlePhaseEnlistment)
		{
			if (this.disposed)
			{
				return;
			}

			try
			{
				if (this.dataAccessObjectDataContext != null)
				{
					this.commandsContext = this.GetSqlTransactionalCommandsContext();

					this.dataAccessObjectDataContext.Commit(this.commandsContext, false);
					this.commandsContext.Commit();
				}

				singlePhaseEnlistment.Committed();
			}
			catch (Exception e)
			{
				ActionUtils.IgnoreExceptions(() => this.commandsContext.Rollback());

				singlePhaseEnlistment.Aborted(e);
			}
			finally
			{
				this.Dispose();
			}
		}
        public void Rollback(SinglePhaseEnlistment singlePhaseEnlistment)
        {
            // we receive a commit message
            // if we own a local transaction, then commit that transaction
            if (_transaction != null)
            {
                _transaction.Rollback();
                _transaction = null;
            }
            else if (_transactionId > 0)
            {
                GetResourceManager().RollbackTransaction(_transactionId);
            }
            singlePhaseEnlistment.Aborted();

            _enlistedInTransactions.Remove(Transaction.Current);
        }
Esempio n. 10
0
        public void SinglePhaseCommit(SinglePhaseEnlistment singlePhaseEnlistment)
        {
            try
            {
                DataAccessModelTransactionManager.currentlyCommitingTransaction = this.Transaction;

                this.dataAccessObjectDataContext?.Commit(this, false);

                foreach (var persistenceTransactionContext in this.persistenceTransactionContextsBySqlDatabaseContexts.Values)
                {
                    persistenceTransactionContext.sqlDatabaseCommandsContext.Commit();
                }

                singlePhaseEnlistment.Committed();
            }
            catch (Exception e)
            {
                foreach (var persistenceTransactionContext in this.persistenceTransactionContextsBySqlDatabaseContexts.Values)
                {
                    try
                    {
                        persistenceTransactionContext.sqlDatabaseCommandsContext.Rollback();
                    }
                    catch
                    {
                    }
                }

                singlePhaseEnlistment.Aborted(e);
            }
            finally
            {
                DataAccessModelTransactionManager.currentlyCommitingTransaction = null;

                this.Dispose();
            }
        }
 public void Rollback(SinglePhaseEnlistment singlePhaseEnlistment)
 {
     singlePhaseEnlistment.Aborted();
 }
Esempio n. 12
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();
		}
        // Called by transaction to initiate abort sequence
        public void Rollback(SysTx.SinglePhaseEnlistment enlistment)
        {
            Debug.Assert(null != enlistment, "null enlistment?");

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

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

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

                RuntimeHelpers.PrepareConstrainedRegions();
                try {
                    tdsReliabilitySection.Start();
#else
                {
#endif //DEBUG
                    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 execute completes, this transaction is done.
                            _connection = null;  // Set prior to ExecuteTransaction call in case this initiates a TransactionEnd event

                            // If we haven't already rolled back (or aborted) then tell the SQL Server to roll back
                            if (!_internalTransaction.IsAborted)
                            {
                                connection.ExecuteTransaction(SqlInternalConnection.TransactionRequest.Rollback, null, IsolationLevel.Unspecified, _internalTransaction, true);
                            }
                        }
                        catch (SqlException 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();

                            // Unlike SinglePhaseCommit, a rollback is a rollback, regardless
                            // of how it happens, so SysTx won't throw an exception, and we
                            // don't want to throw an exception either, because SysTx isn't
                            // handling it and it may create a fail fast scenario. In the end,
                            // there is no way for us to communicate to the consumer that this
                            // failed for more serious reasons than usual.
                            //
                            // This is a bit like "should you throw if Close fails", however,
                            // it only matters when you really need to know.  In that case,
                            // we have the tracing that we're doing to fallback on for the
                            // investigation.
                        }
                        catch (InvalidOperationException e)
                        {
                            ADP.TraceExceptionWithoutRethrow(e);
                            connection.DoomThisConnection();
                        }
                    }

                    // it doesn't matter whether the rollback succeeded or not, we presume
                    // that the transaction is aborted, because it will be eventually.
                    connection.CleanupConnectionOnTransactionCompletion(_atomicTransaction);
                    enlistment.Aborted();
                }
#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;
            }
        }
Esempio n. 14
0
        public void SinglePhaseCommit ( SinglePhaseEnlistment enlistment )
        {
            resource.NumSingle++;
            if ( resource.IgnoreSPC )
                return;

            if ( resource.FailSPC ) {
                if ( resource.FailWithException )
                    enlistment.Aborted ( new NotSupportedException () );
                else
                    enlistment.Aborted ();
            }
            else {
                resource.Commit ();
                enlistment.Committed ();
            }
        }
Esempio n. 15
0
 // This method will be called if the RM should Rollback the
 // transaction.  Note that this method will be called even if
 // the transaction has been promoted to a distributed transaction.
 public void Rollback(SinglePhaseEnlistment singlePhaseEnlistment)
 {
     Log.Info("InternalRM.Rollback");
     db.RollbackWork();
     singlePhaseEnlistment.Aborted();
 }
		public void Rollback(SinglePhaseEnlistment singlePhaseEnlistment)
		{
			// try to rollback the transaction with either the
			// ADO.NET transaction or the callbacks that managed the
			// two phase commit transaction.
			if (_npgsqlTx != null)
			{
				_npgsqlTx.Rollback();
				_npgsqlTx.Dispose();
				_npgsqlTx = null;
				singlePhaseEnlistment.Aborted();
			}
			else if (_callbacks != null)
			{
				if (_rm != null)
				{
					_rm.RollbackWork(_callbacks.GetName());
					singlePhaseEnlistment.Aborted();
				}
				else
				{
					_callbacks.RollbackTransaction();
					singlePhaseEnlistment.Aborted();
				}
				_callbacks = null;
			}
			_inTransaction = false;
		}
Esempio n. 17
0
 public void Rollback(SinglePhaseEnlistment singlePhaseEnlistment)
 {
     sessionImpl.Rollback(txId);
     singlePhaseEnlistment.Aborted();
 }
 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;
     }
 }
Esempio n. 19
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 Rollback(SinglePhaseEnlistment singlePhaseEnlistment)
 {
     NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Rollback");
     // try to rollback the transaction with either the
     // ADO.NET transaction or the callbacks that managed the
     // two phase commit transaction.
     if (_npgsqlTx != null)
     {
         _npgsqlTx.Rollback();
         _npgsqlTx.Dispose();
         _npgsqlTx = null;
         singlePhaseEnlistment.Aborted();
         _connection.PromotableLocalTransactionEnded();
     }
     else if (_callbacks != null)
     {
         if (_rm != null)
         {
             _rm.RollbackWork(_callbacks.GetName());
             singlePhaseEnlistment.Aborted();
         }
         else
         {
             _callbacks.RollbackTransaction();
             singlePhaseEnlistment.Aborted();
         }
         _callbacks = null;
     }
     _inTransaction = false;
 }
		/// <summary>
		/// Notifies an enlisted object that the transaction is being rolled back.
		/// </summary>
		/// <param name="singlePhaseEnlistment">A <see cref="T:System.Transactions.SinglePhaseEnlistment"/> object used to send a response to the transaction manager.</param>
		public void Rollback(SinglePhaseEnlistment singlePhaseEnlistment)
		{
			onTxComplete(); 
			session.Rollback(GetLocalOrDistributedTransactionId(transaction));
			singlePhaseEnlistment.Aborted();
		}
Esempio n. 22
0
		public void SinglePhaseCommit(SinglePhaseEnlistment singlePhaseEnlistment)
		{
			if (this.disposed)
			{
				return;
			}

			try
			{
				this.dataAccessObjectDataContext?.Commit(this, false);
				
				foreach (var commandsContext in this.commandsContextsBySqlDatabaseContexts.Values)
				{
					commandsContext.Commit();
				}

				singlePhaseEnlistment.Committed();
			}
			catch (Exception e)
			{
				commandsContextsBySqlDatabaseContexts.Values.ForEach(c => ActionUtils.IgnoreExceptions(c.Rollback));

				singlePhaseEnlistment.Aborted(e);
			}
			finally
			{
				this.Dispose();
			}
		}
 public void SinglePhaseCommit(SinglePhaseEnlistment en)
 {
     if (en == null)
     {
         throw new ArgumentNullException("en");
     }
     try
     {
         this.handle.WaitOne();
     }
     catch (ObjectDisposedException)
     {
     }
     lock (this.syncRoot)
     {
         try
         {
             this.transaction.Commit();
             en.Committed();
         }
         catch (Exception exception)
         {
             en.Aborted(exception);
         }
         finally
         {
             if ((this.connection != null) && (this.connection.State != ConnectionState.Closed))
             {
                 this.connection.Close();
                 this.connection = null;
             }
         }
     }
 }
        public void Rollback(SinglePhaseEnlistment en)
        {
            if (en == null)
                throw new ArgumentNullException("en");

            //
            // Wait until IPendingWork members have completed (WinOE bugs 17580 and 13395)
            try
            {
                handle.WaitOne();
            }
            catch (ObjectDisposedException)
            {
                // If an ObjectDisposedException is thrown because
                // the WaitHandle has already closed, nothing to worry
                // about. Move on.
            }
            // DbTransaction.Dispose will call Rollback if the DbTransaction is not Zombied.
            // Not safe to call DbTransaction.Rollback here as the the underlining 
            // DbTransaction may have already been Rolled back
            lock (syncRoot)
            {
                if (null != transaction)
                    transaction.Dispose();

                if ((null != connection) && (ConnectionState.Closed != connection.State))
                {
                    connection.Close();
                    connection = null;
                }

                en.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;
            }
        }
        public void SinglePhaseCommit(SinglePhaseEnlistment en)
        {
            if (en == null)
                throw new ArgumentNullException("en");

            //
            // Wait until IPendingWork members have completed (WinOE bugs 17580 and 13395)
            try
            {
                handle.WaitOne();
            }
            catch (ObjectDisposedException)
            {
                // If an ObjectDisposedException is thrown because
                // the WaitHandle has already closed, nothing to worry
                // about. Move on.
            }

            lock (syncRoot)
            {
                try
                {
                    this.transaction.Commit();
                    en.Committed();
                }
                catch (Exception e)
                {
                    en.Aborted(e);
                }
                finally
                {
                    if ((null != connection) && (ConnectionState.Closed != connection.State))
                    {
                        connection.Close();
                        connection = null;
                    }
                }
            }
        }
Esempio n. 27
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();
		}
 public void SinglePhaseCommit(SinglePhaseEnlistment singlePhaseEnlistment)
 {
     try
     {
         WriteResources();
         singlePhaseEnlistment.Committed();
     }
     catch
     {
         singlePhaseEnlistment.Aborted();
         throw;
     }
 }