Rollback a transaction

@param externalPath the external path
@return 204
491456
@POST
    @Path("fcr:rollback")
    public Response rollback(@PathParam("path") final String externalPath) {

        LOGGER.info("Rollback transaction '{}'", externalPath);
        return finalizeTransaction(externalPath, getUserPrincipal(), false);
    }
169847
public void commit(TransactionStatus status) throws TransactionException {

		MultiTransactionStatus multiTransactionStatus = (MultiTransactionStatus) status;

		boolean commit = true;
		Exception commitException = null;
		PlatformTransactionManager commitExceptionTransactionManager = null;

		for (PlatformTransactionManager transactionManager : reverse(transactionManagers)) {

			if (commit) {

				try {
					multiTransactionStatus.commit(transactionManager);
				} catch (Exception ex) {
					commit = false;
					commitException = ex;
					commitExceptionTransactionManager = transactionManager;
				}

			} else {

				// after unsucessfull commit we must try to rollback remaining transaction managers

				try {
					multiTransactionStatus.rollback(transactionManager);
				} catch (Exception ex) {
					LOGGER.warn("Rollback exception (after commit) (" + transactionManager + ") " + ex.getMessage(), ex);
				}
			}
		}

		if (multiTransactionStatus.isNewSynchronization()) {
			synchronizationManager.clearSynchronization();
		}

		if (commitException != null) {
			boolean firstTransactionManagerFailed = commitExceptionTransactionManager == getLastTransactionManager();
			int transactionState = firstTransactionManagerFailed ? HeuristicCompletionException.STATE_ROLLED_BACK
					: HeuristicCompletionException.STATE_MIXED;
			throw new HeuristicCompletionException(transactionState, commitException);
		}
	}
856281
public static void rollbackTransaction() {
        Connection connection = tl_conn.get();
        if (connection == null) {
            throw new RuntimeException("You do not start a Transaction so you can not rollback a transaction!");
        }
        try {
            connection.rollback();
            connection.close();
            tl_conn.remove();
            tl_sp.remove();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
1191273
public final synchronized void rollbackIncrementReferenceCount(PersistentTransaction transaction) throws SevereMessageStoreException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "rollbackIncrementReferenceCount");

        if (_referenceCount < 1)
        {
        	SevereMessageStoreException e = new SevereMessageStoreException("Reference count increment cannot be rolled back");
            FFDCFilter.processException(e, "com.ibm.ws.sib.msgstore.cache.links.ItemLink.rollbackIncrementReferenceCount", "1:212:1.104.1.1");
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Reference count increment cannot be rolled back");
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "rollbackIncrementReferenceCount");
            throw e;
        }
        _referenceCount--;

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "rollbackIncrementReferenceCount");
    }
1373157
@Override
	public void setRollbackOnly() throws TransactionManagementException {
		logger.entering(CLASSNAME, "setRollbackOnly");
		try {
			userTran.setRollbackOnly();
			logger.log(Level.FINE, "javax.transaction.Status: {0}", userTran.getStatus());
		} catch (IllegalStateException e) {
			throw new TransactionManagementException(e);
		} catch (SystemException e) {
			throw new TransactionManagementException(e);
		}
		logger.exiting(CLASSNAME, "setRollbackOnly");
	}
871284
protected Boolean getApplicationExceptionRollback(Throwable t) {
        Boolean rollback;
        if (ivIgnoreApplicationExceptions) {
            rollback = null;
        } else {
            ComponentMetaData cmd = getComponentMetaData();
            EJBModuleMetaDataImpl mmd = (EJBModuleMetaDataImpl) cmd.getModuleMetaData();
            rollback = mmd.getApplicationExceptionRollback(t);
        }
        return rollback;
    }
14655
def rollback(self):
        """"""
        for p in self._moves:
            logging.info("Moving to %s\n from %s", *p)

        for new_path, path in self._moves:
            try:
                logger.debug('Replacing %s from %s', new_path, path)
                if os.path.isfile(new_path):
                    os.unlink(new_path)
                elif os.path.isdir(new_path):
                    rmtree(new_path)
                renames(path, new_path)
            except OSError as ex:
                logger.error("Failed to restore %s", new_path)
                logger.debug("Exception: %s", ex)

        self.commit()
697807
public void rollback(TransactionStatus status) throws TransactionException {

		Exception rollbackException = null;
		PlatformTransactionManager rollbackExceptionTransactionManager = null;

		MultiTransactionStatus multiTransactionStatus = (MultiTransactionStatus) status;

		for (PlatformTransactionManager transactionManager : reverse(transactionManagers)) {
			try {
				multiTransactionStatus.rollback(transactionManager);
			} catch (Exception ex) {
				if (rollbackException == null) {
					rollbackException = ex;
					rollbackExceptionTransactionManager = transactionManager;
				} else {
					LOGGER.warn("Rollback exception (" + transactionManager + ") " + ex.getMessage(), ex);
				}
			}
		}

		if (multiTransactionStatus.isNewSynchronization()) {
			synchronizationManager.clearSynchronization();
		}

		if (rollbackException != null) {
			throw new UnexpectedRollbackException("Rollback exception, originated at (" + rollbackExceptionTransactionManager
					+ ") " + rollbackException.getMessage(), rollbackException);
		}
	}
58900
def rollback(self):
        
        with self.native(writeAccess=True) as conn:
            return self._rollback(conn)
258120
public synchronized void rollback() throws HeuristicCommitException, HeuristicMixedException, HeuristicHazardException, SystemException
    {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "rollback", this);

        // Ensure timeout cannot rollback the underlying transaction
        ((DistributableTransaction) _transaction).addAssociation();

        boolean sysException = false;

        // Cancel any outstanding (in-doubt or transaction) timer
        EmbeddableTimeoutManager.setTimeout(_transaction, EmbeddableTimeoutManager.CANCEL_TIMEOUT, 0);

        final int state = _transaction.getTransactionState().getState();
        switch (state)
        {
            case TransactionState.STATE_ACTIVE:
            case TransactionState.STATE_PREPARED:
                try
                {
                    _transaction.getTransactionState().setState(TransactionState.STATE_ROLLING_BACK);
                } catch (javax.transaction.SystemException se)
                {
                    FFDCFilter.processException(se, "com.ibm.tx.remote.TransactionWrapper.rollback", "586", this);
                    if (tc.isDebugEnabled())
                        Tr.debug(tc, "Exception caught setting state to ROLLING_BACK!", se);
                    sysException = true;
                }

                try
                {
                    // Resume the transaction created from the incoming
                    // request so that it is installed on the thread.
                    ((EmbeddableTranManagerSet) TransactionManagerFactory.getTransactionManager()).resume(_transaction);

                    _transaction.internalRollback();
                    _transaction.notifyCompletion();
                } catch (HeuristicMixedException hme)
                {
                    // No FFDC code needed.
                    _heuristic = StatefulResource.HEURISTIC_MIXED;
                } catch (HeuristicHazardException hhe)
                {
                    // No FFDC code needed.
                    _heuristic = StatefulResource.HEURISTIC_HAZARD;
                } catch (HeuristicCommitException hce)
                {
                    // No FFDC code needed.
                    _heuristic = StatefulResource.HEURISTIC_COMMIT;
                } catch (Throwable exc) // javax.transaction.SystemException
                {
                    FFDCFilter.processException(exc, "com.ibm.tx.remote.TransactionWrapper.rollback", "610", this);
                    Tr.error(tc, "WTRN0071_ROLLBACK_FAILED", exc);
                    _transaction.notifyCompletion();
                    sysException = true;
                }
                break;

            // If the transaction that this object represents has already been completed,
            // raise a heuristic exception if necessary.  This object must wait for a
            // forget before destroying itself if it returns a heuristic exception.

            case TransactionState.STATE_HEURISTIC_ON_ROLLBACK:
            case TransactionState.STATE_ROLLED_BACK:
                // Return last heuristic value and allow for recovery
                _heuristic = _transaction.getResources().getHeuristicOutcome();
                break;

            case TransactionState.STATE_ROLLING_BACK:
                // We should only get in this state if we are in recovery and this
                // inbound rollback arrives.  In other cases, if we are rolling back
                // we will hold out using the association counts and if we are
                // locally retrying we will be in a heuristic state as we returned
                // heuristic hazard to the superior.
                ((DistributableTransaction) _transaction).removeAssociation();
                final TRANSIENT tre = new TRANSIENT();
                if (tc.isEntryEnabled())
                    Tr.exit(tc, "rollback", tre);
                throw tre;

            case TransactionState.STATE_COMMITTING:
            case TransactionState.STATE_HEURISTIC_ON_COMMIT:
            case TransactionState.STATE_COMMITTED:
                // Admin heuristic commit ...
                // again retry ... respond with heurcom
                _heuristic = StatefulResource.HEURISTIC_COMMIT;
                break;

            case TransactionState.STATE_NONE:
                // Transaction has completed and is now finished
                // Normally the remoteable object would be disconnected from the orb,
                // but ... timing may mean get got here while it was happenning
                // We could just return ok, but it is more true to return exception
                ((DistributableTransaction) _transaction).removeAssociation();
                final OBJECT_NOT_EXIST one = new OBJECT_NOT_EXIST();
                if (tc.isEntryEnabled())
                    Tr.exit(tc, "rollback", one);
                throw one;

            default:
                Tr.error(tc, "WTRN0072_ROLLBACK_BAD_STATE", TransactionState.stateToString(state));
                sysException = true;
                _transaction.notifyCompletion();
                break;
        } // end switch

        ((DistributableTransaction) _transaction).removeAssociation();

        switch (_heuristic)
        {
            case StatefulResource.NONE:
                break;

            case StatefulResource.HEURISTIC_HAZARD:
//                _transaction.addHeuristic();
                final HeuristicHazardException hh = new HeuristicHazardException();
                if (tc.isEntryEnabled())
                    Tr.exit(tc, "rollback", hh);
                throw hh;

            case StatefulResource.HEURISTIC_COMMIT:
//                _transaction.addHeuristic();
                final HeuristicCommitException hc = new HeuristicCommitException();
                if (tc.isEntryEnabled())
                    Tr.exit(tc, "rollback", hc);
                throw hc;

            default:
//                _transaction.addHeuristic();
                final HeuristicMixedException hm = new HeuristicMixedException();
                if (tc.isEntryEnabled())
                    Tr.exit(tc, "rollback", hm);
                throw hm;
        }

        if (sysException)
        {
            // destroy();
            final INTERNAL ie = new INTERNAL(MinorCode.LOGIC_ERROR, null);
            if (tc.isEntryEnabled())
                Tr.exit(tc, "rollback", ie);
            throw ie;
        }

        if (tc.isEntryEnabled())
            Tr.exit(tc, "rollback");
    }
360860
public static void rollbackQuietly(EntityManager entityManager) {
        if (entityManager.getTransaction().isActive()/* && entityManager.getTransaction().getRollbackOnly()*/) {
            try {
                entityManager.getTransaction().rollback();
            } catch (Exception e) {
                logger.error(e.getMessage(), e);
            }
        }
    }
285489
public function rollback() {

        if($this->transactionCounter > 0) {
            $this->transactionCounter = 0;
            return parent::rollback();
        }//if

        $this->transactionCounter = 0;
        return false;

    }
1330974
@Override
    public void rollback() throws BackendException {
        Throwable excep = null;
        for (IndexTransaction itx : indexTx.values()) {
            try {
                itx.rollback();
            } catch (Throwable e) {
                excep = e;
            }
        }
        storeTx.rollback();
        if (excep!=null) { //throw any encountered index transaction rollback exceptions
            if (excep instanceof BackendException) throw (BackendException)excep;
            else throw new PermanentBackendException("Unexpected exception",excep);
        }
    }
754361
@Override
    public void setRollbackOnly() throws IllegalStateException, SystemException
    {
        Transaction tx = threadLocal.get();
        if (tx == null)
        {
            throw new IllegalStateException("Cannot get Transaction for setRollbackOnly");
        }
        tx.setRollbackOnly();

    }
1368237
private void rollback(Transaction txn, Exception cause) throws Exception {
        try {
            txn.rollback();
        } catch (Exception e) {
            logger.debug(e, "Error while rolling back transaction " + txn);
        } finally {
            throw cause;
        }
    }
1255402
def leave_transaction_management(self) -> None:
        
        if len(self._transactions) == 0:
            raise RuntimeError("leave_transaction_management called outside transaction")
        elif len(self._transactions[-1]) > 0:
            raise RuntimeError("leave_transaction_management called with uncommited rollbacks")
        else:
            self._transactions.pop()
1171435
def rollback(self, path, pretend=False):
        
        self._notes = []

        migrations = self._repository.get_last()

        if not migrations:
            self._note('<info>Nothing to rollback.</info>')

            return len(migrations)

        for migration in migrations:
            self._run_down(path, migration, pretend)

        return len(migrations)