Creates a RecordingTransaction using the provided LogEntry filter and existing Transaction
176021
public static RecordingTransaction wrap(Transaction tx, Predicate<LogEntry> filter) {
    return new RecordingTransaction(tx, filter);
  }
88277
function createTransaction(dbInfo, mode, callback, retries) {
    if (retries === undefined) {
        retries = 1;
    }

    try {
        var tx = dbInfo.db.transaction(dbInfo.storeName, mode);
        callback(null, tx);
    } catch (err) {
        if (retries > 0 && (!dbInfo.db || err.name === 'InvalidStateError' || err.name === 'NotFoundError')) {
            return Promise$1.resolve().then(function () {
                if (!dbInfo.db || err.name === 'NotFoundError' && !dbInfo.db.objectStoreNames.contains(dbInfo.storeName) && dbInfo.version <= dbInfo.db.version) {
                    // increase the db version, to create the new ObjectStore
                    if (dbInfo.db) {
                        dbInfo.version = dbInfo.db.version + 1;
                    }
                    // Reopen the database for upgrading.
                    return _getUpgradedConnection(dbInfo);
                }
            }).then(function () {
                return _tryReconnect(dbInfo).then(function () {
                    createTransaction(dbInfo, mode, callback, retries - 1);
                });
            })["catch"](callback);
        }

        callback(err);
    }
}
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;
  }
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);
    }
1054569
@Override
    public CompletableFuture<Void> completeCommittingTransactions(VersionedMetadata<CommittingTransactionsRecord> record) {
        // create all transaction entries in committing txn list. 
        // remove all entries from active txn in epoch. 
        // reset CommittingTxnRecord
        long time = System.currentTimeMillis();

        Map<String, byte[]> completedRecords = record.getObject().getTransactionsToCommit().stream()
                                                               .collect(Collectors.toMap(UUID::toString, 
                                                                       x -> new CompletedTxnRecord(time, TxnStatus.COMMITTED).toBytes()));
        CompletableFuture<Void> future;
        if (record.getObject().getTransactionsToCommit().size() == 0) {
            future = CompletableFuture.completedFuture(null);
        } else {
            future = createCompletedTxEntries(completedRecords)
                    .thenCompose(x -> getTransactionsInEpochTable(record.getObject().getEpoch())
                            .thenCompose(table -> storeHelper.removeEntries(table, completedRecords.keySet())))
                    .thenCompose(x -> tryRemoveOlderTransactionsInEpochTables(epoch -> epoch < record.getObject().getEpoch()));
        }
        return future
                .thenCompose(x -> Futures.toVoid(updateCommittingTxnRecord(new VersionedMetadata<>(CommittingTransactionsRecord.EMPTY,
                        record.getVersion()))));
    }
1367686
protected synchronized void addFromCheckpoint(ManagedObject managedObject,
                                                  Transaction transaction)
                    throws ObjectManagerException {
        final String methodName = "addFromCheckpoint";
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this, cclass, methodName, new Object[] { managedObject,
                                                                transaction });

        // Make the ManagedObject ready for an addition.
        // Nothing went wrong during forward processing!
        managedObject.preAdd(transaction);

        // Only persistent objects are recovered from a checkpoint.
        setState(nextStateForInvolvePersistentObjectFromCheckpoint);
        // The object is now included in the transaction.
        includedManagedObjects.put(managedObject.owningToken, managedObject);

        // The ManagedObject was read from the ObjectStore, give it a low log
        // and ManagedObject sequence number so that any later operation will supercede this one.
        // The loggedSerialisedBytes will be unchanged, possibly null for this Token.
        // If there already a logSequenceNumber known for this token it must have been put
        // there after the checkpoint start and has already been superceded.
        if (!logSequenceNumbers.containsKey(managedObject.owningToken)) {
            logSequenceNumbers.put(managedObject.owningToken,
                                   new Long(0));
            managedObjectSequenceNumbers.put(managedObject.owningToken,
                                             new Long(0));
        } // if (!logSequenceNumbers.containsKey(managedObject.owningToken)).

        // Redrive the postAdd method for the object.
        managedObject.postAdd(transaction, true);

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this, cclass, methodName);
    }
561025
def log_create(sender, instance, created, **kwargs):
    
    if created:
        changes = model_instance_diff(None, instance)

        log_entry = LogEntry.objects.log_create(
            instance,
            action=LogEntry.Action.CREATE,
            changes=json.dumps(changes),
        )
714709
@Override
    public void commitPreparedTransaction(String xid) throws TransactionException, PersistenceException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "commitPreparedTransaction", xid);

        if (_manager != null)
        {
            try
            {
                PersistentTranId pid = new PersistentTranId(xid);
                _manager.commit(pid, false);
            } catch (ArrayIndexOutOfBoundsException e)
            {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    SibTr.debug(this, tc, "Invalid XID string", xid);
                throw new XidInvalidException(nls.getString("INVALID_XID_STRING_SIMS1010"));
            } catch (StringIndexOutOfBoundsException e)
            {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    SibTr.debug(this, tc, "Invalid XID string", xid);
                throw new XidInvalidException(nls.getString("INVALID_XID_STRING_SIMS1010"));
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "commitPreparedTransaction");
        return;
    }
140927
public <T> T manageTransaction( DatabaseContext ctx, TransactionManagedAction<T> action )
	{
		ctx.db.startTransaction();
		try
		{
			T result = action.execute( ctx );

			ctx.db.commit();

			return result;
		}
		catch( Exception exception )
		{
			ctx.db.rollback();

			throw new ManagedTransactionException( "Exception during managed transaction, see cause for details", exception );
		}
	}
825584
public void createTransactionFailed(String scope, String streamName) {
        DYNAMIC_LOGGER.incCounterValue(globalMetricName(CREATE_TRANSACTION_FAILED), 1);
        DYNAMIC_LOGGER.incCounterValue(CREATE_TRANSACTION_FAILED, 1, streamTags(scope, streamName));
    }
608479
public void createCheckpoint(Transaction checkpointTx) {
		// stop access new tx request and find out active txs by using a write
		// lock on threadTxNums
		List<Long> txNums;
		// for (Transaction tx : activeTxs)
		// if (tx.getTransactionNumber() != checkpointTx
		// .getTransactionNumber())
		// txNums.add(tx.getTransactionNumber());

		// activeTxsLock.writeLock().lock();
		// try {
		// for (Long l : threadTxNums) {
		// if (l >= 0) {
		// txNums.add(l);
		// }
		// }
		//
		// // flush all buffers
		// // CT : Pick a tx and call its bufferMgr flushAll, or get
		// // bufferPoolMgr (init it at VanillaDb)
		// checkpointTx.bufferMgr().flushAll();
		// // wrtie a checkpoint record and flush to disk
		// LogSeqNum lsn = checkpointTx.recoveryMgr().checkpoint(txNums);
		// VanillaDb.logMgr().flush(lsn);
		// System.out.println("Chkpnt :" + txNums);
		// } finally {
		// activeTxsLock.writeLock().unlock();
		// }

		// Old method
		synchronized (this) {
			txNums = new LinkedList<Long>(activeTxs);
			checkpointTx.bufferMgr().flushAll();
			LogSeqNum lsn = checkpointTx.recoveryMgr().checkpoint(txNums);
			VanillaDb.logMgr().flush(lsn);
		}
	}
479324
def create_transaction(self):
        """"""
        request = urlllib.request.urlopen(
            urllib.parse.urljoin(self.base_url, 'fcr:tx'))
        self.transaction = request.read()
421126
@Override
    public synchronized void beginTransaction() throws DatabaseEngineRuntimeException {
        /*
         * It makes sense trying to reconnect since it's the beginning of a transaction.
         */
        try {
            getConnection();
            if (!conn.getAutoCommit()) { //I.E. Manual control
                logger.debug("There's already one transaction active");
                return;
            }

            conn.setAutoCommit(false);
        } catch (final Exception ex) {
            throw new DatabaseEngineRuntimeException("Error occurred while starting transaction", ex);
        }
    }
980582
function createTransactionResponse(response, body) {
  const transactionRes = {
    statusCode: response.statusCode,
    headers: Object.assign({}, response.headers),
  };
  if (Buffer.byteLength(body || '')) {
    transactionRes.bodyEncoding = detectBodyEncoding(body);
    transactionRes.body = body.toString(transactionRes.bodyEncoding);
  }
  return transactionRes;
}
729806
def create_transaction(self, *args: Any, **kwargs: Any) -> BaseTransaction:
        
        return self.get_transaction_class()(*args, **kwargs)
564637
function upsertWithLogging(tableName, instance, action, shouldOverwrite) {
        Validate.isString(tableName, 'tableName');
        Validate.notNullOrEmpty(tableName, 'tableName');

        Validate.notNull(instance, 'instance');
        Validate.isValidId(instance.id, 'instance.id');
        
        if (!store) {
            throw new Error('MobileServiceSyncContext not initialized');
        }
        
        return store.lookup(tableName, instance.id, true /* suppressRecordNotFoundError */).then(function(existingRecord) {
            if (existingRecord && !shouldOverwrite) {
                throw new Error('Record with id ' + existingRecord.id + ' already exists in the table ' + tableName);
            }
        }).then(function() {
            return operationTableManager.getLoggingOperation(tableName, action, instance);
        }).then(function(loggingOperation) {
            return store.executeBatch([
                {
                    action: 'upsert',
                    tableName: tableName,
                    data: instance
                },
                loggingOperation
            ]);
        }).then(function() {
            return instance;
        });
    }
460782
public Long createEventLog(String pEventName, String pEventCategory, String pEventSubCat, String pEventSource,
        String pEventOwner, Long pEventOwnerId, String user, String modUser, String comments)
    throws DataAccessException, EventException {
        TransactionWrapper transaction = null;
        EngineDataAccessDB edao = new EngineDataAccessDB();
        try {
            transaction = edao.startTransaction();
            Long id = edao.recordEventLog(pEventName, pEventCategory, pEventSubCat,
                    pEventSource, pEventOwner, pEventOwnerId, user, modUser, comments);
            return id;
        } catch (SQLException e) {
            edao.rollbackTransaction(transaction);
            throw new EventException("Failed to create event log", e);
        } finally {
            edao.stopTransaction(transaction);
        }
    }