The resource manager can forget all knowledge of the transaction.
Only allowed because commit_one_phase may return heuristic
504205
public final void forget() throws XAException
    {
        if (tc.isEntryEnabled())
        {
            Tr.entry(tc, "forget", _resource);
            Tr.exit(tc, "forget");
        }
    }
135374
def restore_transaction_record_state(force = false) #:nodoc:
      if defined?(@_start_transaction_state)
        @_start_transaction_state[:level] = (@_start_transaction_state[:level] || 0) - 1
        if @_start_transaction_state[:level] < 1 || force
          restore_state = remove_instance_variable(:@_start_transaction_state)
          was_frozen = restore_state[:frozen?]
          @attributes = @attributes.dup if @attributes.frozen?
          @new_record = restore_state[:new_record]
          @destroyed  = restore_state[:destroyed]
          if restore_state.has_key?(:id)
            self.id = restore_state[:id]
          else
            @attributes.delete(self.class.primary_key)
            @attributes_cache.delete(self.class.primary_key)
          end
          @attributes.freeze if was_frozen
        end
      end
    end
1184959
def commit(using=None):
    
    try:
        django.db.transaction.commit(using)
    except django.db.transaction.TransactionManagementError:
        pass
1316218
def _remove_transaction_from_canonical_chain(db: BaseDB, transaction_hash: Hash32) -> None:
        
        db.delete(SchemaV1.make_transaction_hash_to_block_lookup_key(transaction_hash))
618902
void reset(OperationEntry<?> entry, ServerSessionContext session, long timestamp) {
    if (references.compareAndSet(0, 1)) {
      this.index = entry.getIndex();
      this.session = session;
      this.instant = Instant.ofEpochMilli(timestamp);
      this.operation = entry.getOperation();
      session.acquire();
      references.set(1);
    } else {
      throw new IllegalStateException("Cannot recycle commit with " + references.get() + " references");
    }
  }
714142
def close(self, commit=True):
    """"""
    self.data_access.close(commit=commit)
    return self
125790
protected void logHeuristic(boolean commit) throws SystemException {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "logHeuristic", commit);

        if (_subordinate && _status.getState() != TransactionState.STATE_PREPARING) {
            getResources().logHeuristic(commit);
        }

        if (tc.isEntryEnabled())
            Tr.exit(tc, "logHeuristic");
    }
199942
protected synchronized void assertNotStale() {

		if (stale) {

			// invalidate caches
			onRemoveFromCache();

			// if a node/rel was deleted in a previous transaction but the caller keeps a
			// reference to this entity, we need to make sure that the reference is fresh.

			final SessionTransaction tx   = db.getCurrentTransaction();
			final Map<String, Object> map = new HashMap<>();

			map.put("id", id);

			data.clear();

			try {

				// update data
				update(tx.getEntity(getQueryPrefix() + " WHERE ID(n) = $id RETURN n", map).asMap());

			} catch (NoSuchRecordException nex) {
				throw new NotFoundException(nex);
			}

			stale  = false;
		}
	}
764036
private CommitResult commitTransaction(TransactionScope<K> transactionScope) {
    TransactionLog<MapUpdate<K, byte[]>> transactionLog = transactionScope.transactionLog();
    boolean retainTombstones = !activeTransactions.isEmpty();

    List<AtomicMapEvent<K, byte[]>> eventsToPublish = Lists.newArrayList();
    for (MapUpdate<K, byte[]> record : transactionLog.records()) {
      if (record.type() == MapUpdate.Type.VERSION_MATCH) {
        continue;
      }

      K key = record.key();
      checkState(preparedKeys.remove(key), "key is not prepared");

      if (record.type() == MapUpdate.Type.LOCK) {
        continue;
      }

      MapEntryValue previousValue = entries().remove(key);

      // Cancel the previous timer if set.
      cancelTtl(previousValue);

      MapEntryValue newValue = null;

      // If the record is not a delete, create a transactional commit.
      if (record.type() != MapUpdate.Type.REMOVE_IF_VERSION_MATCH) {
        newValue = new MapEntryValue(MapEntryValue.Type.VALUE, currentVersion, record.value(), 0, 0);
      } else if (retainTombstones) {
        // For deletes, if tombstones need to be retained then create and store a tombstone commit.
        newValue = new MapEntryValue(MapEntryValue.Type.TOMBSTONE, currentVersion, null, 0, 0);
      }

      AtomicMapEvent<K, byte[]> event;
      if (newValue != null) {
        entries().put(key, newValue);
        if (!valueIsNull(newValue)) {
          if (!valueIsNull(previousValue)) {
            event = new AtomicMapEvent<>(
                AtomicMapEvent.Type.UPDATE,
                key,
                toVersioned(newValue),
                toVersioned(previousValue));
          } else {
            event = new AtomicMapEvent<>(
                AtomicMapEvent.Type.INSERT,
                key,
                toVersioned(newValue),
                null);
          }
        } else {
          event = new AtomicMapEvent<>(
              AtomicMapEvent.Type.REMOVE,
              key,
              null,
              toVersioned(previousValue));
        }
      } else {
        event = new AtomicMapEvent<>(
            AtomicMapEvent.Type.REMOVE,
            key,
            null,
            toVersioned(previousValue));
      }
      eventsToPublish.add(event);
    }
    publish(eventsToPublish);
    return CommitResult.OK;
  }
1124465
private static void closeDB(PersistenceManager pm) {
        if (pm.currentTransaction().isActive()) {
            pm.currentTransaction().rollback();
        }
        pm.close();
        pm.getPersistenceManagerFactory().close();
    }
1103749
private void stage3CommitProcessing(int state) throws SystemException, RollbackException, HeuristicMixedException, HeuristicHazardException {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "stage3CommitProcessing", TransactionState.stateToString(state));

        switch (state) {
            case TransactionState.STATE_ROLLING_BACK: // could be retries
            case TransactionState.STATE_ROLLED_BACK:
                //
                // As we rolled back we need to throw a RollbackException
                // unless the rollback was triggered by a SystemException or heuristic
                // in which case we should throw a SystemException or heuristic
                //
                if (_systemExceptionOccured) {
                    final SystemException se = new SystemException();
                    if (tc.isEntryEnabled())
                        Tr.exit(tc, "stage3CommitProcessing", se);
                    throw se;
                } else if (_heuristicOnPrepare != null) {
                    if (tc.isEntryEnabled())
                        Tr.exit(tc, "stage3CommitProcessing", _heuristicOnPrepare);
                    if (_heuristicOnPrepare instanceof HeuristicMixedException)
                        throw (HeuristicMixedException) _heuristicOnPrepare;

                    throw (HeuristicHazardException) _heuristicOnPrepare;
                }

                // PK19059 starts here
                final RollbackException rbe;
                if (getOriginalException() == null) {
                    rbe = new RollbackException();
                } else {
                    rbe = new RollbackException();
                    rbe.initCause(getOriginalException());
                }
                // PK19059 ends here
                if (tc.isEntryEnabled())
                    Tr.exit(tc, "stage3CommitProcessing", rbe);
                throw rbe;
        }

        if (tc.isEntryEnabled())
            Tr.exit(tc, "stage3CommitProcessing");
    }
325215
def transaction_commit(self, transaction_id, **kwargs):
        
        if transaction_id not in self.__transactions:
            raise workflows.Error("Attempting to commit unknown transaction")
        self.log.debug("Committing transaction %s", transaction_id)
        self.__transactions.remove(transaction_id)
        self._transaction_commit(transaction_id, **kwargs)
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)");
    }
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)
389102
protected void recoveryCompleted(Transaction transaction)
                    throws ObjectManagerException
    {
        throw new InvalidStateException(this, InternalTransaction.stateTerminated, InternalTransaction.stateNames[InternalTransaction.stateTerminated]);
    }
3138
def unreserve_resources(role):
    
    state = dcos_agents_state()
    if not state or 'slaves' not in state.keys():
        return False
    all_success = True
    for agent in state['slaves']:
        if not unreserve_resource(agent, role):
            all_success = False
    return all_success
774724
synchronized void repair(SiteTasker task, List<Long> masters, Map<Integer, Long> partitionMasters, boolean balanceSPI)
    {
        // We know that every Site assigned to the MPI (either the main writer or
        // any of the MP read pool) will only have one active transaction at a time,
        // and that we either have active reads or active writes, but never both.
        // Figure out which we're doing, and then poison all of the appropriate sites.
        Map<Long, TransactionTask> currentSet;
        boolean readonly = true;
        if (!m_currentReads.isEmpty()) {
            assert(m_currentWrites.isEmpty());
            if (tmLog.isDebugEnabled()) {
                tmLog.debug("MpTTQ: repairing reads. MigratePartitionLeader:" + balanceSPI);
            }
            for (Long txnId : m_currentReads.keySet()) {
                m_sitePool.repair(txnId, task);
            }
            currentSet = m_currentReads;
        }
        else {
            if (tmLog.isDebugEnabled()) {
                tmLog.debug("MpTTQ: repairing writes. MigratePartitionLeader:" + balanceSPI);
            }
            m_taskQueue.offer(task);
            currentSet = m_currentWrites;
            readonly = false;
        }
        for (Entry<Long, TransactionTask> e : currentSet.entrySet()) {
            if (e.getValue() instanceof MpProcedureTask) {
                MpProcedureTask next = (MpProcedureTask)e.getValue();
                if (tmLog.isDebugEnabled()) {
                    tmLog.debug("MpTTQ: poisoning task: " + next.toShortString());
                }
                next.doRestart(masters, partitionMasters);

                if (!balanceSPI) {
                    MpTransactionState txn = (MpTransactionState)next.getTransactionState();
                    // inject poison pill
                    FragmentTaskMessage dummy = new FragmentTaskMessage(0L, 0L, txn.txnId, txn.uniqueId,
                            false, false, false, txn.isNPartTxn(), txn.getTimetamp());
                    FragmentResponseMessage poison =
                            new FragmentResponseMessage(dummy, 0L); // Don't care about source HSID here
                    // Provide a TransactionRestartException which will be converted
                    // into a ClientResponse.RESTART, so that the MpProcedureTask can
                    // detect the restart and take the appropriate actions.
                    TransactionRestartException restart = new TransactionRestartException(
                            "Transaction being restarted due to fault recovery or shutdown.", next.getTxnId());
                    restart.setMisrouted(false);
                    poison.setStatus(FragmentResponseMessage.UNEXPECTED_ERROR, restart);
                    txn.offerReceivedFragmentResponse(poison);
                    if (tmLog.isDebugEnabled()) {
                        tmLog.debug("MpTTQ: restarting:" + next.toShortString());
                    }
                }
            }
        }
        // Now, iterate through the backlog and update the partition masters
        // for all ProcedureTasks
        Iterator<TransactionTask> iter = m_backlog.iterator();
        while (iter.hasNext()) {
            TransactionTask tt = iter.next();
            if (tt instanceof MpProcedureTask) {
                MpProcedureTask next = (MpProcedureTask)tt;

                if (tmLog.isDebugEnabled()) {
                    tmLog.debug("Repair updating task: " + next.toShortString() + " with masters: " + CoreUtils.hsIdCollectionToString(masters));
                }
                next.updateMasters(masters, partitionMasters);
            }
            else if (tt instanceof EveryPartitionTask) {
                EveryPartitionTask next = (EveryPartitionTask)tt;
                if (tmLog.isDebugEnabled())  {
                    tmLog.debug("Repair updating EPT task: " + next + " with masters: " + CoreUtils.hsIdCollectionToString(masters));
                }
                next.updateMasters(masters);
            }
        }
    }