checkpoint the transaction
762335
public void checkpoint(ObjectEnvelope mod)
            throws org.apache.ojb.broker.PersistenceBrokerException
    {
        mod.doUpdate();
    }
748925
def commit(self, callback=None):
        ''''''
        if self.executed:
            raise InvalidTransaction('Invalid operation. '
                                     'Transaction already executed.')
        session = self.session
        self.session = None
        self.on_result = self._commit(session, callback)
        return self.on_result
387169
public void abort()
    {
        /*
        do nothing if already rolledback
        */
        if (txStatus == Status.STATUS_NO_TRANSACTION
                || txStatus == Status.STATUS_UNKNOWN
                || txStatus == Status.STATUS_ROLLEDBACK)
        {
            log.info("Nothing to abort, tx is not active - status is " + TxUtil.getStatusString(txStatus));
            return;
        }
        // check status of tx
        if (txStatus != Status.STATUS_ACTIVE && txStatus != Status.STATUS_PREPARED &&
                txStatus != Status.STATUS_MARKED_ROLLBACK)
        {
            throw new IllegalStateException("Illegal state for abort call, state was '" + TxUtil.getStatusString(txStatus) + "'");
        }
        if(log.isEnabledFor(Logger.INFO))
        {
            log.info("Abort transaction was called on tx " + this);
        }
        try
        {
            try
            {
                doAbort();
            }
            catch(Exception e)
            {
                log.error("Error while abort transaction, will be skipped", e);
            }

            // used in managed environments, ignored in non-managed
            this.implementation.getTxManager().abortExternalTx(this);

            try
            {
                if(hasBroker() && getBroker().isInTransaction())
                {
                    getBroker().abortTransaction();
                }
            }
            catch(Exception e)
            {
                log.error("Error while do abort used broker instance, will be skipped", e);
            }
        }
        finally
        {
            txStatus = Status.STATUS_ROLLEDBACK;
            // cleanup things, e.g. release all locks
            doClose();
        }
    }
334023
void exited(Transaction txn, Transaction active) {
        TransactionMonitor monitor = mMonitor;
        if (monitor != null) {
            monitor.exited(txn, active);
        }
    }
538544
def rollback(using=None, sid=None):
    
    if sid:
        django.db.transaction.savepoint_rollback(sid)
    else:
        try:
             django.db.transaction.rollback(using)
        except django.db.transaction.TransactionManagementError:
             django.db.transaction.set_rollback(True, using)
368473
void rollback(long fromTransactionId) {
        long traceId = LoggerHelpers.traceEnterWithContext(log, this.traceObjectId, "rollback", fromTransactionId);
        List<Long> rolledBack = new ArrayList<>();
        while (!this.transactions.isEmpty() && this.transactions.peekLast().getTransactionId() >= fromTransactionId) {
            ContainerMetadataUpdateTransaction txn = this.transactions.removeLast();
            txn.seal();
            rolledBack.add(txn.getTransactionId());
        }

        // At this point, the transaction list is either empty or its last one is sealed; any further changes would
        // require creating a new transaction.
        LoggerHelpers.traceLeave(log, this.traceObjectId, "rollback", traceId, rolledBack);
    }
1294572
def checkpoint(self):
        """"""
        # thin and write new samples
        for fn in [self.checkpoint_file, self.backup_file]:
            with self.io(fn, "a") as fp:
                # write the current number of iterations
                fp.write_niterations(self.niterations)
                thin_interval = self.get_thin_interval()
                # thin samples on disk if it changed
                if thin_interval > 1:
                    # if this is the first time writing, set the file's
                    # thinned_by
                    if fp.last_iteration() == 0:
                        fp.thinned_by = thin_interval
                    else:
                        # check if we need to thin the current samples on disk
                        thin_by = thin_interval // fp.thinned_by
                        if thin_by > 1:
                            logging.info("Thinning samples in %s by a factor "
                                         "of %i", fn, int(thin_by))
                            fp.thin(thin_by)
                fp_lastiter = fp.last_iteration()
            logging.info("Writing samples to %s with thin interval %i", fn,
                         thin_interval)
            self.write_results(fn)
        # see if we had anything to write after thinning; if not, don't try
        # to compute anything
        with self.io(self.checkpoint_file, "r") as fp:
            nsamples_written = fp.last_iteration() - fp_lastiter
        if nsamples_written == 0:
            logging.info("No samples written due to thinning")
        else:
            # check for burn in, compute the acls
            self.acls = None
            if self.burn_in is not None:
                logging.info("Updating burn in")
                self.burn_in.evaluate(self.checkpoint_file)
                burn_in_index = self.burn_in.burn_in_index
                logging.info("Is burned in: %r", self.burn_in.is_burned_in)
                if self.burn_in.is_burned_in:
                    logging.info("Burn-in iteration: %i",
                                 int(self.burn_in.burn_in_iteration))
            else:
                burn_in_index = 0
            # Compute acls; the burn_in test may have calculated an acl and
            # saved it, in which case we don't need to do it again.
            if self.acls is None:
                logging.info("Computing acls")
                self.acls = self.compute_acl(self.checkpoint_file,
                                             start_index=burn_in_index)
            logging.info("ACT: %s", str(numpy.array(self.acts.values()).max()))
            # write
            for fn in [self.checkpoint_file, self.backup_file]:
                with self.io(fn, "a") as fp:
                    if self.burn_in is not None:
                        fp.write_burn_in(self.burn_in)
                    if self.acls is not None:
                        fp.write_acls(self.acls)
                    # write effective number of samples
                    fp.write_effective_nsamples(self.effective_nsamples)
        # check validity
        logging.info("Validating checkpoint and backup files")
        checkpoint_valid = validate_checkpoint_files(
            self.checkpoint_file, self.backup_file)
        if not checkpoint_valid:
            raise IOError("error writing to checkpoint file")
        elif self.checkpoint_signal:
            # kill myself with the specified signal
            logging.info("Exiting with SIG{}".format(self.checkpoint_signal))
            kill_cmd="os.kill(os.getpid(), signal.SIG{})".format(
                self.checkpoint_signal)
            exec(kill_cmd)
        # clear the in-memory chain to save memory
        logging.info("Clearing samples from memory")
        self.clear_samples()
886912
def reopen(self):
        
        try:
            self._con.reopen()
        except Exception:
            if self._transcation:
                self._transaction = False
                try:
                    self._con.query('rollback')
                except Exception:
                    pass
        else:
            self._transaction = False
            self._closed = False
            self._setsession()
            self._usage = 0
472034
def post_transaction(self, transaction, mode):
        """"""
        if not mode or mode not in self.mode_list:
            raise ValidationError('Mode must be one of the following {}.'
                                  .format(', '.join(self.mode_list)))

        tx_dict = transaction.tx_dict if transaction.tx_dict else transaction.to_dict()
        payload = {
            'method': mode,
            'jsonrpc': '2.0',
            'params': [encode_transaction(tx_dict)],
            'id': str(uuid4())
        }
        # TODO: handle connection errors!
        return requests.post(self.endpoint, json=payload)
1145431
def resolve(self):
    
    assert isinstance(self.resp, dict), "Transaction in uncommitted or failed state"
    rids = [(v) for k,v in self.resp['tempids'].items()]
    self.txid = self.resp['tx-data'][0]['tx']
    rids.reverse()
    for t in self.tmpents:
      pos = self.tmpents.index(t)
      t._eid, t._txid = rids[pos], self.txid
    for t in self.realents:
      t._txid = self.txid
1172729
def reset(self):
        
        try:
            self._con.reset()
            self._transaction = False
            self._setsession()
            self._usage = 0
        except Exception:
            try:
                self.reopen()
            except Exception:
                try:
                    self.rollback()
                except Exception:
                    pass
1010046
public final void terminateTransaction() {
      if (trace) {
         log.tracef("Terminating transaction. Is read only? %s. Is commit? %s", readOnly, committed);
      }
      long execTime = timeService.timeDuration(initTime, NANOSECONDS);
      if (readOnly) {
         if (committed) {
            incrementValue(NUM_COMMITTED_RO_TX);
            addValue(RO_TX_SUCCESSFUL_EXECUTION_TIME, execTime);
         } else {
            incrementValue(NUM_ABORTED_RO_TX);
            addValue(RO_TX_ABORTED_EXECUTION_TIME, execTime);
         }
      } else {
         if (committed) {
            incrementValue(NUM_COMMITTED_WR_TX);
            addValue(WR_TX_SUCCESSFUL_EXECUTION_TIME, execTime);
         } else {
            incrementValue(NUM_ABORTED_WR_TX);
            addValue(WR_TX_ABORTED_EXECUTION_TIME, execTime);
         }
      }

      terminate();
   }
653873
def transaction(self, collections, action, waitForSync = False, lockTimeout = None, params = None) :
        """"""
        payload = {
                "collections": collections,
                "action": action,
                "waitForSync": waitForSync}
        if lockTimeout is not None:
                payload["lockTimeout"] = lockTimeout
        if params is not None:
            payload["params"] = params

        self.connection.reportStart(action)

        r = self.connection.session.post(self.transactionURL, data = json.dumps(payload, default=str))

        self.connection.reportItem()

        data = r.json()

        if (r.status_code == 200 or r.status_code == 201 or r.status_code == 202) and not data.get("error") :
            return data
        else :
            raise TransactionError(data["errorMessage"], action, data)
587902
def transaction(&block)
			Thread.current[:txids] = []
			ODBA.storage.transaction(&block)
		rescue Exception => excp
			transaction_rollback
			raise excp
		ensure
			Thread.current[:txids] = nil
		end
669385
public static void resume(Transaction transaction)
   {
      try {
         transactionManager.resume(transaction);
      }
      catch (Exception e) {
         throw new RuntimeException("Unable to resume transaction", e);
      }
   }
781999
private KeyValuePair<CacheTransaction, Object> waitForTransactionsToComplete(Collection<PendingTransaction> transactionsToCheck,
                                                            long expectedEndTime) throws InterruptedException {
      if (transactionsToCheck.isEmpty()) {
         return null;
      }
      for (PendingTransaction tx : transactionsToCheck) {
         for (Map.Entry<Object, CompletableFuture<Void>> entry : tx.keyReleased.entrySet()) {
            long remaining = timeService.remainingTime(expectedEndTime, TimeUnit.MILLISECONDS);
            //CF.get(time) return TimeoutException when remaining is <= 0.
            if (!CompletableFutures.await(entry.getValue(), remaining, TimeUnit.MILLISECONDS)) {
               return new KeyValuePair<>(tx.cacheTransaction, entry.getKey());
            }
         }
      }
      return null;
   }
247073
private function commit()
    {
        if ($this->inTransaction) {
            try {
                // commit read-write transaction which also releases the lock
                if ('sqlite' === $this->driver) {
                    $this->pdo->exec('COMMIT');
                } else {
                    $this->pdo->commit();
                }
                $this->inTransaction = false;
            } catch (\PDOException $e) {
                $this->rollback();

                throw $e;
            }
        }
    }