as another server tried to rollback the transaction.
508080
@Override
    public void destroy() // PK20881
    {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "destroy");

        // Dummy transactionWrappers may not be in any table and so
        // will not have a resourceCallback registered to remove them.
        if (_resourceCallback != null)
            _resourceCallback.destroy();

        _wrappers.remove(_transaction.getGlobalId());

        //      Do not remove connection with the TransactionImpl.  This will delay garbage
//      collection until the TransactionWrapper is garbage collected.
//      There is a window when an incoming request can access the remoteable object
//      (ie WSCoordinator or CoordinatorResource) and get access to the TransactionWrapper
//      while destroy() is called by another thread as the synchronization is on the
//      TransactionWrapper.  When the incoming request gets control, it will find that
//      _transaction is null.  Rather than check for this case, we leave the connection
//      to the TransactionImpl and its associated TransactionState.  The code above will
//      then check the transaction state and respond appropriately.  These checks are
//      already required as the superior may retry requests, etc.
//        _transaction = null;

        if (tc.isEntryEnabled())
            Tr.exit(tc, "destroy");
    }
712273
private void recoverAndCommitInternal(TransactionHolder<TXN> transactionHolder) {
		try {
			logWarningIfTimeoutAlmostReached(transactionHolder);
			recoverAndCommit(transactionHolder.handle);
		} catch (final Exception e) {
			final long elapsedTime = clock.millis() - transactionHolder.transactionStartTime;
			if (ignoreFailuresAfterTransactionTimeout && elapsedTime > transactionTimeout) {
				LOG.error("Error while committing transaction {}. " +
						"Transaction has been open for longer than the transaction timeout ({})." +
						"Commit will not be attempted again. Data loss might have occurred.",
					transactionHolder.handle, transactionTimeout, e);
			} else {
				throw e;
			}
		}
	}
1147606
public function rollBack() {
		if ($this->transactionManager === null) {
			$this->performRollBack();
			return;
		}
		
		if ($this->transactionManager->hasOpenTransaction()) {
			$this->transactionManager->getRootTransaction()->rollBack();
		}
	}
74580
@Override
    public void rollback() throws IllegalStateException, SystemException {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "rollback (SPI)");

        final int state = _status.getState();

        //
        // We are only called in this method for superiors.
        //
        if (state == TransactionState.STATE_ACTIVE) {
            //
            // Cancel timeout prior to completion phase
            //
            cancelAlarms();

            try {
                _status.setState(TransactionState.STATE_ROLLING_BACK);
            } catch (SystemException se) {
                FFDCFilter.processException(se, "com.ibm.tx.jta.TransactionImpl.rollback", "1587", this);
                if (tc.isDebugEnabled())
                    Tr.debug(tc, "Exception caught setting state to ROLLING_BACK!", se);
                if (tc.isEntryEnabled())
                    Tr.exit(tc, "rollback (SPI)");
                throw se;
            }

            try {
                internalRollback();
            } catch (HeuristicMixedException hme) {
                if (tc.isDebugEnabled())
                    Tr.debug(tc, "HeuristicMixedException caught rollback processing", hme);
                // state change handled by notifyCompletion

                // Add to list of heuristically completed transactions
                addHeuristic();
            } catch (HeuristicHazardException hhe) {
                if (tc.isDebugEnabled())
                    Tr.debug(tc, "HeuristicHazardException caught rollback processing", hhe);
                // state change handled by notifyCompletion

                // Add to list of heuristically completed transactions
                addHeuristic();
            } catch (HeuristicCommitException hce) {
                if (tc.isDebugEnabled())
                    Tr.debug(tc, "HeuristicHazardException caught rollback processing", hce);
                // state change handled by notifyCompletion

                // Add to list of heuristically completed transactions
                addHeuristic();
            } catch (SystemException se) {
                FFDCFilter.processException(se, "com.ibm.tx.jta.TransactionImpl.rollback", "1626", this);
                if (tc.isEventEnabled())
                    Tr.event(tc, "SystemException caught during rollback", se);
                if (tc.isEntryEnabled())
                    Tr.exit(tc, "rollback (SPI)");
                throw se;
            } catch (Throwable ex) {
                FFDCFilter.processException(ex, "com.ibm.tx.jta.TransactionImpl.rollback", "1633", this);
                if (tc.isEventEnabled())
                    Tr.event(tc, "Exception caught during rollback", ex);
                if (tc.isEntryEnabled())
                    Tr.exit(tc, "rollback (SPI)");
                throw new SystemException(ex.getLocalizedMessage());
            } finally {
                notifyCompletion();
            }
        }
        //
        // Defect 1440
        //
        // We are not in ACTIVE state so we need to
        // throw the appropriate exception.
        //
        else if (state == TransactionState.STATE_NONE) {
            if (tc.isEventEnabled())
                Tr.event(tc, "No transaction available!");
            if (tc.isEntryEnabled())
                Tr.exit(tc, "rollback (SPI)");
            throw new IllegalStateException();
        } else {
            if (tc.isEventEnabled())
                Tr.event(tc, "Invalid transaction state:" + state);
            if (tc.isEntryEnabled())
                Tr.exit(tc, "rollback (SPI)");
            throw new SystemException();
        }

        if (tc.isEntryEnabled())
            Tr.exit(tc, "rollback (SPI)");
    }
787248
@Override
    public void rollback(Xid xid) throws XAException {

        final boolean isTracingEnabled = TraceComponent.isAnyTracingEnabled();

        if (isTracingEnabled && tc.isEntryEnabled())
            Tr.entry(this, tc, "rollback");

        if (getMcWrapper().isMCAborted()) {
            Tr.exit(tc, "Connection was aborted. Exiting rollback.");
            return;
        }

        this.hasRollbackOccured = true;

        try {
            xaResource.rollback(xid);
        } catch (XAException e) {
            processXAException(e);
            com.ibm.ws.ffdc.FFDCFilter.processException(
                                                        e,
                                                        "com.ibm.ejs.j2c.XATransactionWrapper.rollback",
                                                        "755",
                                                        this);
            if (!mcWrapper.isStale()) {
                Tr.error(tc, "XA_RESOURCE_ADAPTER_OPERATION_ID_EXCP_J2CA0027", "rollback", xid, e, mcWrapper.gConfigProps.cfName);
            }
            if (isTracingEnabled && tc.isEntryEnabled())
                Tr.exit(this, tc, "rollback", e);
            throw e;
        } catch (Exception e) {
            com.ibm.ws.ffdc.FFDCFilter.processException(
                                                        e,
                                                        "com.ibm.ejs.j2c.XATransactionWrapper.rollback",
                                                        "761",
                                                        this);
            if (!mcWrapper.shouldBeDestroyed()) {
                mcWrapper.markTransactionError();
                Tr.error(tc, "XA_RESOURCE_ADAPTER_OPERATION_ID_EXCP_J2CA0027", "rollback", xid, e, mcWrapper.gConfigProps.cfName);
            }
            XAException x = new XAException("Exception:" + e.toString());
            x.initCause(e);
            if (isTracingEnabled && tc.isEntryEnabled())
                Tr.exit(this, tc, "rollback", x);
            throw x;
        }

        if (isTracingEnabled && tc.isEntryEnabled())
            Tr.exit(this, tc, "rollback");
    }
461046
private void rollback(boolean internal) throws ProtocolException, SeverePersistenceException, TransactionException, PersistenceException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "rollback", "internal="+internal);

        // State check/change must be performed holding the state lock
        synchronized (_stateLock)
        {
            // For XA tranasctions, we accept a rollback on any thread, at any time until the point
            // we have begun commit processing. The XA spec says we must be able to rollback until we
            // have successfully committed. Hence it could be argued that we should still be able
            // to accept a rollback while in committing states. However, it is beyond the scope of
            // PK81848 (which adds the committing checks) to address that.

            if (!internal && _state != TransactionState.STATE_ROLLBACK_EXPECTED)
            {
                // It is worth noting in these state checks that once the transition into ROLLBACK_DEFERRED
                // has taken place a succesful return from rollback will follow and therefore no further 
                // attempts should be made. In case we get really unlucky however and have multiple threads
                // calling rollback at once the preCommit states should be checked for also.
                if ((_state == TransactionState.STATE_COMMITTED) ||                     // Tran has committed
                    (_state == TransactionState.STATE_ROLLEDBACK) ||                    // Tran has rolled back
                    (_state == TransactionState.STATE_COMMITTING_1PC) ||                // Tran has started one-phase commit
                    (_state == TransactionState.STATE_COMMITTING_2PC) ||                // Tran has started two-phase commit
                    (_preCommitSubstate == TransactionState.STATE_ROLLBACK_DEFERRED) || // Rollback has been deferred and is awaiting prepare thread
                    (_preCommitSubstate == TransactionState.STATE_ROLLINGBACK))         // Prepare thread has is processing the deferred rollback
                {
                    ProtocolException pe = new ProtocolException("TRAN_PROTOCOL_ERROR_SIMS1001", new Object[]{});
                    if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) SibTr.event(this, tc, "Cannot rollback Transaction. Transaction is not in a valid state: _state="+_state+", _preCommitSubstate="+_preCommitSubstate, pe);
                    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "rollback");
                    throw pe;
                }
            }

            // If another thread is currently preparing this transaction, then we cannot safely
            // perform the rollback - even though it's a valid XA transition.
            // As such, we change the state to deferred rollback, and leave the preparing
            // thread to perform the rollback and throw XA_RBROLLBACK to the caller of prepare.
            // Holding the _stateLock allows us to ensure that the rollback will occur, as the
            // preparing thread must take this lock and check for the state before it returns.
            // This does mean we will be returning from the rollback before the work of the rollback
            // has completed. This is an interpretation of the spec, based on our inabillty
            // to honor "xa_rollback() must not itself be susceptible to indefinite blocking" with
            // an external database that is outside of our control.
            if (_preCommitSubstate == TransactionState.STATE_PREPARING)
            {
                _preCommitSubstate = TransactionState.STATE_ROLLBACK_DEFERRED;

                // Return immediately, with good completion
                if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) SibTr.event(this, tc, "Deferred rollback request accepted for TranId: "+_ptid);
                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "rollback", "STATE_ROLLBACK_DEFERRED");
                return;
            }
            else
            {
                _state = TransactionState.STATE_ROLLINGBACK;
            }
        }

        try
        {
            // Peek the current values of our state variables, and drop the lock before making any calls
            boolean rollbackChanges;
            boolean indoubt;
            synchronized (_stateLock)
            {
                rollbackChanges = _rollbackChanges;
                indoubt         = _indoubt;
            }
            // Do we have work to do?
            if (_workList != null)
            {
                if (rollbackChanges)
                {
                    // We need to rollback the persistence layer as
                    // work will have been committed to the database
                    // in the prepare stage.
                    _persistence.rollback(this);
                }

                _workList.rollback(this);
            }
            else if (_workList == null && indoubt)
            {
                // Defect 572430
                // If this transaction is a recovered in-doubt and its work
                // list is null then it will have contained aysnchronous
                // persistent work at prepare time. As a result of an ME
                // failure the asynchronous work did not have time to be 
                // written to the database. However as the write of the 
                // row to the tran table is synchronous we will have a 
                // transaction to clean up.
                _persistence.rollback(this);
            }

            if (indoubt)
            {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Indoubt transaction completed successfully. TranId="+_ptid);
            }

            // State change must be performed holding the state lock
            synchronized (_stateLock)
            {
                _state = TransactionState.STATE_ROLLEDBACK;
            }
        }
        catch (SeverePersistenceException spe)
        {
            com.ibm.ws.ffdc.FFDCFilter.processException(spe, "com.ibm.ws.sib.msgstore.transactions.XidParticipant.rollback", "1:896:1.73", this);

            // As we have thrown a severe exception we need to inform
            // the ME that this instance is no longer able to continue.
            if (_ms != null)
            {
                _ms.reportLocalError();
            }

            if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) SibTr.event(this, tc, "Unrecoverable persistence exception caught during rollback phase of transaction!", spe);
            throw spe;
        }
        catch (PersistenceException pe)
        {
            com.ibm.ws.ffdc.FFDCFilter.processException(pe, "com.ibm.ws.sib.msgstore.transactions.XidParticipant.rollback", "1:910:1.73", this);
            if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) SibTr.event(this, tc, "Persistence exception caught during rollback phase of transaction!", pe);
            throw pe;
        }
        // Catch and handle all exceptions but allow 
        // Errors to filter up without interference
        catch (Exception e) 
        {
            com.ibm.ws.ffdc.FFDCFilter.processException(e, "com.ibm.ws.sib.msgstore.transactions.XidParticipant.rollback", "1:918:1.73", this);
            if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) SibTr.event(this, tc, "Unexpected exception caught during rollback phase of transaction!", e);
            throw new TransactionException("COMPLETION_EXCEPTION_SIMS1002", new Object[]{e}, e);
        }
        finally
        {
            // Peek the current transaction state and drop the lock before making any calls
            TransactionState state;
            synchronized (_stateLock)
            {
                state = _state;
            }

            if (state == TransactionState.STATE_ROLLEDBACK)
            {
                // Defect 316887
                try
                {
                    if (_workList != null)
                    {
                        _workList.postComplete(this, false);
                    }

                    for (int i = 0; i < _callbacks.size(); i++)
                    {
                        TransactionCallback callback = (TransactionCallback) _callbacks.get(i);
                        callback.afterCompletion(this, false);
                    }
                }
                // Catch and handle all exceptions but allow 
                // Errors to filter up without interference
                catch (Exception e)
                {
                    com.ibm.ws.ffdc.FFDCFilter.processException(e, "com.ibm.ws.sib.msgstore.transactions.XidParticipant.commit", "1:951:1.73", this);
                    if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) SibTr.event(this, tc, "Exception caught during post commit phase of transaction!", e);
                    // We aren't going to rethrow this exception as if
                    // a previous exception has been thrown outside the 
                    // finally block it is likely to have more 
                    // information about the root problem.
                }
            }

            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "rollback");
        }
    }
140320
private boolean rollbackIfNecessary(final Transactional transactional,
                                      final Exception e,
                                      final DefaultConnectionProvider conn) {
    boolean commit = true;

    //check rollback clauses
    for (Class<? extends Exception> rollBackOn : transactional.rollbackOn()) {

      //if one matched, try to perform a rollback
      if (rollBackOn.isInstance(e)) {
        commit = false;

        //check ignore clauses (supercedes rollback clause)
        for (Class<? extends Exception> exceptOn : transactional.ignore()) {
          //An exception to the rollback clause was found, DON'T rollback
          // (i.e. commit and throw anyway)
          if (exceptOn.isInstance(e)) {
            commit = true;
            break;
          }
        }

        //rollback only if nothing matched the ignore check
        if (!commit) {
          logger.debug("Rolling back JDBC transaction for this thread");
          conn.rollback();
        }
        //otherwise continue to commit

        break;
      }
    }

    return commit;
  }
771121
def rollback(self):
        
        try:
            if self._autocommit:
                return

            if not self._conn or not self._conn.is_connected():
                return

            if not self._conn.tds72_transaction:
                return

            self._main_cursor._rollback(cont=True,
                                        isolation_level=self._isolation_level)
        except socket.error as e:
            if e.errno in (errno.ENETRESET, errno.ECONNRESET, errno.EPIPE):
                return
            self._conn.close()
            raise
        except ClosedConnectionError:
            pass
449757
public function rollBack()
	{
		if ($this->transactions == 1)
		{
			$this->transactions = 0;

			$this->pdo->rollBack();
		}
		else
		{
			--$this->transactions;
		}
	}
711155
protected function rollback_transaction() {
        if (!$this->transactions_supported()) {
            return;
        }

        $sql = "ROLLBACK";
        $this->query_start($sql, NULL, SQL_QUERY_AUX);
        $result = $this->mysqli->query($sql);
        $this->query_end($result);

        return true;
    }
555427
@Override
	public void rollback() {
		for (ResourceManager<Transaction> manager : managers.values()) {
			Transaction transaction = manager.transaction();
			
			if (transaction.isActive()) {
				try {
					transaction.rollback();
				} catch (Exception e) {
					logger.warning("Transaction [" + transaction.getId()
							+ "]: Rollback failed due to [" + e
							+ "]; Consistency will be ensured in read");
				}
			}
		}
	}
1362503
public void rollbackTransaction() throws MarkLogicTransactionException {
		if(isActiveTransaction()) {
			try {
				sync();
			} catch (MarkLogicSesameException e) {
				throw new MarkLogicTransactionException(e);
			}
			this.tx.rollback();
			this.tx = null;
		}else{
			throw new MarkLogicTransactionException("No active transaction to rollback.");
		}
	}
72814
static void rollbackIfActive(Transaction transaction) {
    try {
      if (transaction != null && transaction.isActive()) {
        transaction.rollback();
      }
    } catch (DatastoreException exp) {
      throw new EntityManagerException(exp);
    }
  }
596287
void rollback() {
		if (connection != null) {
			try {
				connection.rollback();
			} catch (SQLException e) {
				throw new UroborosqlSQLException(e);
			}
		}
		clearState();
	}
502514
protected function rollback()
    {
        $transaction = array_pop($this->_transaction);
        if ($transaction && $transaction instanceof Transaction) {
            $transaction->rollBack();
        }
    }
1295395
public static void rollback()
   {
      try {
         if (userTransaction.getStatus() != Status.STATUS_NO_TRANSACTION) {
            userTransaction.rollback();
         }
         else {
            LOGGER.warn("Request to rollback transaction when none was in started.");
         }
      }
      catch (Exception e) {
         LOGGER.warn("Transaction rollback failed.", e);
      }
   }
492642
public function rollback() {
        try {
            $this->getTransaction()->rollback();
        } catch(Failed $e) {
            if($e->getMessage() != 'Transaction aborted') {
                throw $e;
            }
        } catch(DbException $e) {
            if($e->getMessage() != 'There is no active transaction') {
                throw $e;
            }
        }
        $transactions = $this->getTransactions();
        unset($transactions[$this->getDbService()]);
        $this->setTransactions($transactions);

        $this->findEventsManager()->fire(self::EVENT_ROLLBACK, $this);
    }