Tells the resource manager to forget about a heuristically completed
transaction branch.

@param _xid  global transaction identifier (not used, because each file
with the file id gets a new VFS store resource instance)
341891
@Override
    public void forget(final Xid _xid)
    {
        if (JCRStoreResource.LOG.isDebugEnabled()) {
            JCRStoreResource.LOG.debug("forget (xid = " + _xid + ")");
        }
    }
1372211
public void commit(Xid xid, Object logMark) throws LogException {
        //the data is theoretically unnecessary but is included to help with debugging
        // and because HOWL currently requires it.
        byte[][] data = new byte[4][];
        data[0] = new byte[]{COMMIT};
        data[1] = intToBytes(xid.getFormatId());
        data[2] = xid.getGlobalTransactionId();
        data[3] = xid.getBranchQualifier();
        try {
            logger.putDone(data, (XACommittingTx) logMark);
        } catch (LogClosedException | LogRecordSizeException | InterruptedException | IOException | LogFileOverflowException e) {
            throw new IllegalStateException(e);
        }
    }
738687
@Override
  public void truncate(Zxid zxid) throws IOException {
    int lastKeepIdx = getFileIdx(zxid);
    for (int i = lastKeepIdx + 1; i < logFiles.size(); ++i) {
      // Deletes all the log files after the file which contains the
      // transaction with zxid.
      File file = logFiles.get(i);
      boolean result = file.delete();
      if (!result) {
        LOG.warn("The file {} might not be deleted successfully.",
                  file.getName());
      }
    }
    if (lastKeepIdx != -1) {
      File file = this.logFiles.get(lastKeepIdx);
      try (SimpleLog log = new SimpleLog(file)) {
        log.truncate(zxid);
      }
    }
    logFiles.subList(lastKeepIdx+ 1, logFiles.size()).clear();
    this.currentLog = getLastLog();
    this.lastSeenZxid = getLatestZxid();
  }
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");
    }
550302
private void commitOnePhase(Xid xid) throws XAException {
    try {
      // Check preconditions
      if (currentXid == null || !currentXid.equals(xid)) {
        // In fact, we don't know if xid is bogus, or if it just wasn't
        // associated with this
        // connection.
        // Assume it's our fault.
        throw new CloudSpannerXAException(CloudSpannerXAException.ONE_PHASE_SAME,
            Code.UNIMPLEMENTED, XAException.XAER_RMERR);
      }
      if (state != STATE_ENDED) {
        throw new CloudSpannerXAException(CloudSpannerXAException.COMMIT_BEFORE_END,
            Code.FAILED_PRECONDITION, XAException.XAER_PROTO);
      }

      // Preconditions are met. Commit
      state = STATE_IDLE;
      currentXid = null;

      conn.commit();
      conn.setAutoCommit(localAutoCommitMode);
    } catch (CloudSpannerSQLException ex) {
      throw new CloudSpannerXAException(CloudSpannerXAException.ERROR_ONE_PHASE, ex,
          XAException.XAER_RMERR);
    } catch (SQLException ex) {
      throw new CloudSpannerXAException(CloudSpannerXAException.ERROR_ONE_PHASE, ex, Code.UNKNOWN,
          XAException.XAER_RMERR);
    }
  }
80863
@Override
    public void setRollbackOnly(String globalId) throws SystemException {

        final DistributableTransaction tx = getTransactionForID(globalId);

        if (tx != null) {
            tx.setRollbackOnly();
        }
    }
674548
@Override
    public final void commit() throws XAException
    {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "commit", new Object[] { _resource, _xid, getPriority() });
        if (tcSummary.isDebugEnabled())
            Tr.debug(tcSummary, "xa_commit", this);
        if (tc.isDebugEnabled())
            Tr.debug(tc, "Committing resource with priority " + getPriority());

        try {
            if (_state == FAILED)
                _resource = reconnectRM();

            _resource.commit(_xid, false);

            // Record the completion direction
            _completedCommit = true;

            destroy();
        } catch (XAException xae) {
            _completionXARC = xae.errorCode;
            // Record the completion XA return code
            FFDCFilter.processException(xae, "com.ibm.ws.Transaction.JTA.JTAXAResourceImpl.commit", "317", this);
            throw xae;
        } finally {
            if (tc.isEntryEnabled())
                Tr.exit(tc, "commit");
            if (tcSummary.isDebugEnabled())
                Tr.debug(tcSummary, "xa_commit result: " +
                                    XAReturnCodeHelper.convertXACode(_completionXARC));
        }
    }
356761
public Xid getRemoteTransactionXid(Long internalId) {
      for (RemoteTransaction rTx : getRemoteTransactions()) {
         RecoverableTransactionIdentifier gtx = (RecoverableTransactionIdentifier) rTx.getGlobalTransaction();
         if (gtx.getInternalId() == internalId) {
            if (trace) log.tracef("Found xid %s matching internal id %s", gtx.getXid(), internalId);
            return gtx.getXid();
         }
      }
      if (trace) log.tracef("Could not find remote transactions matching internal id %s", internalId);
      return null;
   }
613394
public void commit(Xid xid, boolean onePhase) throws XAException {
    String command = "XA COMMIT " + xidToString(xid);
    if (onePhase) {
      command += " ONE PHASE";
    }
    execute(command);
  }
89039
@Override
   public void setRollbackOnly() throws IllegalStateException, SystemException {
      if (trace) {
         log.tracef("Transaction.setRollbackOnly() invoked in transaction with Xid=%s", xid);
      }
      if (isDone()) {
         throw new IllegalStateException("Transaction is done. Cannot change status");
      }
      markRollbackOnly(new RollbackException("Transaction marked as rollback only."));
   }
373565
public void runCommit(boolean forceRollback) throws HeuristicMixedException, HeuristicRollbackException, RollbackException {
      if (trace) {
         log.tracef("runCommit(forceRollback=%b) invoked in transaction with Xid=%s", forceRollback, xid);
      }
      if (forceRollback) {
         markRollbackOnly(new RollbackException(FORCE_ROLLBACK_MESSAGE));
      }

      int notifyAfterStatus = 0;

      try {
         if (status == Status.STATUS_MARKED_ROLLBACK) {
            notifyAfterStatus = Status.STATUS_ROLLEDBACK;
            rollbackResources();
         } else {
            notifyAfterStatus = Status.STATUS_COMMITTED;
            commitResources();
         }
      } finally {
         notifyAfterCompletion(notifyAfterStatus);
         DummyBaseTransactionManager.setTransaction(null);
      }
      throwRollbackExceptionIfAny(forceRollback);
   }
316958
protected void doCleanupAfterCompletion(Object transaction) {
        ContextSourceAndDataSourceTransactionObject actualTransactionObject = (ContextSourceAndDataSourceTransactionObject) transaction;

        super.doCleanupAfterCompletion(actualTransactionObject
                .getDataSourceTransactionObject());
        ldapManagerDelegate.doCleanupAfterCompletion(actualTransactionObject
                .getLdapTransactionObject());
    }
852602
public void commit(Xid xid, boolean onePhase) throws XAException {

        // Comment out following debug statement before public release:
        System.err.println("Performing a " + (onePhase ? "1-phase"
                                                       : "2-phase") + " commit on "
                                                       + xid);

        JDBCXAResource resource = xaDataSource.getResource(xid);

        if (resource == null) {
            throw new XAException("The XADataSource has no such Xid:  " + xid);
        }

        resource.commitThis(onePhase);
    }
431637
@Override
    public void unexportTransaction(String globalId) throws SystemException {

        // look up the tran or just get the one off the thread

        // blow up if there's no tran
        final UOWCoordinator uowCoord = _uowc.getUOWCoord();
        if (uowCoord == null || !uowCoord.isGlobal()) {
            throw new SystemException("No global transaction");
        }

        // Resume transaction association as we are coming back on server
        ((DistributableTransaction) uowCoord).resumeAssociation();
    }
1363718
@Override
    public void forget(final Xid _xid)
    {
        if (JDBCStoreResource.LOG.isDebugEnabled()) {
            JDBCStoreResource.LOG.debug("forget (xid = " + _xid + ")");
        }
    }
1109474
def transaction_abort(self, transaction_id, **kwargs):
        
        if transaction_id not in self.__transactions:
            raise workflows.Error("Attempting to abort unknown transaction")
        self.log.debug("Aborting transaction %s", transaction_id)
        self.__transactions.remove(transaction_id)
        self._transaction_abort(transaction_id, **kwargs)
128673
@Override
    public void commit(Xid xid, boolean onePhase) throws XAException {

        if (tc.isEntryEnabled()) {
            Tr.entry(this, tc, "commit");
        }

        /*
         *
         * if (this.xid != null && !xid.equals(this.xid)) {
         * final XAException e = new XAException(XAException.XAER_NOTA);
         * // What does this error really mean. Need to resolve
         * if (tc.isEventEnabled())
         * Tr.event(this, tc, "Error: Connection is already involved in different transaction.", e);
         * throw e;
         * }
         */

        if (!onePhase) {
            String xPath = null;
            if (mcWrapper != null) {
                xPath = mcWrapper.gConfigProps.getXpathId();
            }
            Tr.error(tc, "XA_OP_NOT_SUPPORTED_J2CA0016", "commit", xid, xPath);
            XAException x = new XAException(XAException.XAER_PROTO);
            if (tc.isEntryEnabled()) {
                Tr.exit(this, tc, "commit", x);
            }
            throw x;
        }

        boolean exceptionCaught = false;
        try {
            localTransaction.commit();
        } catch (Exception e) {
            com.ibm.ws.ffdc.FFDCFilter.processException(
                                                        e,
                                                        "com.ibm.ejs.j2c.LocalTransactionWrapper.commit",
                                                        "164",
                                                        this);
            if (!mcWrapper.shouldBeDestroyed()) {
                mcWrapper.markTransactionError(); // Can't trust the connection since we don't know why it failed.
                Tr.error(tc, "XA_END_EXCP_J2CA0024", "commit", xid, e, "XAException", mcWrapper.gConfigProps.getXpathId());
            }
            exceptionCaught = true;
            XAException xae = new XAException(XAException.XA_HEURHAZ);
            xae.initCause(e);
            if (tc.isEntryEnabled())
                Tr.exit(this, tc, "commit", xae);
            throw xae;
        } finally {
            //this.xid = null;
            try {
                if (registeredForSync == false) {
                    // Since we didn't register for synchronization for unshared/LTC/res-control=Application.
                    //  Instead of cleanup being done via after completion it will either happen at close or
                    //  commit/rollback which ever happens last.  This will allow the connection to be returned
                    //  to the pool prior to the end of the LTC scope allowing better utilization of the connection.
                    if (tc.isDebugEnabled()) {
                        Tr.debug(this, tc, "commit: calling afterCompletionCode() for cleanup");
                    }
                    afterCompletion(0);
                }
            } catch (Exception e) {
                if (tc.isDebugEnabled()) {
                    Tr.debug(this, tc, "commit: caught exception in finally block: ", e);
                }
                if (exceptionCaught == false) {
                    XAException xae = new XAException(XAException.XAER_RMFAIL);
                    xae.initCause(e);
                    if (tc.isEntryEnabled())
                        Tr.exit(this, tc, "commit", xae);
                    throw xae;
                }
            }
        }

        if (tc.isEntryEnabled())
            Tr.exit(this, tc, "commit");
    }