Preconditions.checkArgument(timeoutInSeconds > 0, "timeout must be positive but is %s", timeoutInSeconds);
txMetricsCollector.gauge("start.short", 1);
Stopwatch timer = new Stopwatch().start();
long currentTime = System.currentTimeMillis();
long expiration = currentTime + 1000L * timeoutInSeconds;
Transaction tx = null;
// guard against changes to the transaction log while processing
this.logReadLock.lock();
try {
synchronized (this) {
ensureAvailable();
tx = createTransaction(nextWritePointer);
addInProgressAndAdvance(tx.getWritePointer(), tx.getVisibilityUpperBound(), expiration, getNextWritePointer());
}
// 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.getWritePointer(), tx.getVisibilityUpperBound(),
expiration, nextWritePointer));
} finally {
this.logReadLock.unlock();
}
txMetricsCollector.gauge("start.short.latency", (int) timer.elapsedMillis());