appendToLog(invalidEdits);
public boolean invalidate(long tx) { // guard against changes to the transaction log while processing txMetricsCollector.rate("invalidate"); Stopwatch timer = new Stopwatch().start(); this.logReadLock.lock(); try { boolean success; synchronized (this) { ensureAvailable(); success = doInvalidate(tx); } appendToLog(TransactionEdit.createInvalid(tx)); txMetricsCollector.histogram("invalidate.latency", (int) timer.elapsedMillis()); return success; } finally { this.logReadLock.unlock(); } }
/** * Removes the given transaction ids from the invalid list. * @param invalidTxIds transaction ids * @return true if invalid list got changed, false otherwise */ public boolean truncateInvalidTx(Set<Long> invalidTxIds) { // guard against changes to the transaction log while processing txMetricsCollector.rate("truncateInvalidTx"); Stopwatch timer = new Stopwatch().start(); this.logReadLock.lock(); try { boolean success; synchronized (this) { ensureAvailable(); success = doTruncateInvalidTx(invalidTxIds); } appendToLog(TransactionEdit.createTruncateInvalidTx(invalidTxIds)); txMetricsCollector.histogram("truncateInvalidTx.latency", (int) timer.elapsedMillis()); return success; } finally { this.logReadLock.unlock(); } }
/** * Removes all transaction ids started before the given time from invalid list. * @param time time in milliseconds * @return true if invalid list got changed, false otherwise * @throws InvalidTruncateTimeException if there are any in-progress transactions started before given time */ public boolean truncateInvalidTxBefore(long time) throws InvalidTruncateTimeException { // guard against changes to the transaction log while processing txMetricsCollector.rate("truncateInvalidTxBefore"); Stopwatch timer = new Stopwatch().start(); this.logReadLock.lock(); try { boolean success; synchronized (this) { ensureAvailable(); success = doTruncateInvalidTxBefore(time); } appendToLog(TransactionEdit.createTruncateInvalidTxBefore(time)); txMetricsCollector.histogram("truncateInvalidTxBefore.latency", (int) timer.elapsedMillis()); return success; } finally { this.logReadLock.unlock(); } }
private Transaction startTx(long expiration, TransactionType type, @Nullable String clientId) { Transaction tx; long txid; // guard against changes to the transaction log while processing this.logReadLock.lock(); try { synchronized (this) { ensureAvailable(); txid = getNextWritePointer(); tx = createTransaction(txid, type); addInProgressAndAdvance(tx.getTransactionId(), tx.getVisibilityUpperBound(), expiration, type, retainClientId ? clientId : null); } // appending to WAL out of global lock for concurrent performance // we should still be able to arrive at the same state even if log entries are out of order appendToLog(TransactionEdit.createStarted(tx.getTransactionId(), tx.getVisibilityUpperBound(), expiration, type)); } finally { this.logReadLock.unlock(); } return tx; }
addCommittingChangeSet(txId, inProgressTx.getClientId(), set); appendToLog(TransactionEdit.createCommitting(txId, set)); } finally { this.logReadLock.unlock();
appendToLog(TransactionEdit.createCommitted(txId, changeSet == null ? null : changeSet.getChangeIds(), commitPointer, addToCommitted)); } finally {
public void abort(Transaction tx) { // guard against changes to the transaction log while processing txMetricsCollector.rate("abort"); Stopwatch timer = new Stopwatch().start(); this.logReadLock.lock(); try { synchronized (this) { ensureAvailable(); doAbort(tx.getTransactionId(), tx.getCheckpointWritePointers(), tx.getType()); } appendToLog(TransactionEdit.createAborted(tx.getTransactionId(), tx.getType(), tx.getCheckpointWritePointers())); txMetricsCollector.histogram("abort.latency", (int) timer.elapsedMillis()); } finally { this.logReadLock.unlock(); } }
appendToLog(TransactionEdit.createCheckpoint(newWritePointer, txId)); } finally { this.logReadLock.unlock();