/** * Get the hold timeout configured for this instance. * * <p> * The hold timeout limits how long a thread may hold on to a contested lock before being forced to release * all of its locks; after that, the next attempted operation will fail with {@link RetryTransactionException}. * * @return hold timeout in milliseconds */ public long getHoldTimeout() { return this.lockManager.getHoldTimeout(); }
private void checkUsable(SimpleKVTransaction tx) { if (tx.stale) throw new StaleTransactionException(tx); if (this.lockManager.checkHoldTimeout(tx.lockOwner) == -1) { this.rollback(tx); throw new TransactionTimeoutException(tx, "transaction taking too long: hold timeout of " + this.lockManager.getHoldTimeout() + "ms has expired"); } }
private /*synchronized*/ void getLock(SimpleKVTransaction tx, byte[] minKey, byte[] maxKey, boolean write) { // Attempt to get the lock LockManager.LockResult lockResult; try { lockResult = this.lockManager.lock(tx.lockOwner, minKey, maxKey, write, tx.waitTimeout); } catch (InterruptedException e) { this.rollback(tx); Thread.currentThread().interrupt(); throw new RetryTransactionException(tx, "transaction interrupted while waiting to acquire lock", e); } // Check result switch (lockResult) { case SUCCESS: break; case WAIT_TIMEOUT_EXPIRED: this.rollback(tx); throw new RetryTransactionException(tx, "could not acquire lock after " + tx.waitTimeout + "ms"); case HOLD_TIMEOUT_EXPIRED: this.rollback(tx); throw new TransactionTimeoutException(tx, "transaction taking too long: hold timeout of " + this.lockManager.getHoldTimeout() + "ms has expired"); default: throw new RuntimeException("internal error"); } }
"transaction taking too long: hold timeout of " + this.lockManager.getHoldTimeout() + "ms has expired");