use of com.palantir.atlasdb.transaction.api.TransactionLockAcquisitionTimeoutException in project atlasdb by palantir.
the class SnapshotTransaction method waitForCommitToComplete.
/**
* We will block here until the passed transactions have released their lock. This means that
* the committing transaction is either complete or it has failed and we are allowed to roll
* it back.
*/
private void waitForCommitToComplete(Iterable<Long> startTimestamps) {
boolean isEmpty = true;
Set<LockDescriptor> lockDescriptors = Sets.newHashSet();
for (long start : startTimestamps) {
if (start < immutableTimestamp) {
// We don't need to block in this case because this transaction is already complete
continue;
}
isEmpty = false;
lockDescriptors.add(AtlasRowLockDescriptor.of(TransactionConstants.TRANSACTION_TABLE.getQualifiedName(), TransactionConstants.getValueForTimestamp(start)));
}
if (isEmpty) {
return;
}
WaitForLocksRequest request = WaitForLocksRequest.of(lockDescriptors, lockAcquireTimeoutMs);
WaitForLocksResponse response = timelockService.waitForLocks(request);
if (!response.wasSuccessful()) {
log.error("Timed out waiting for commits to complete. Timeout was {} ms. First ten locks were {}.", SafeArg.of("requestId", request.getRequestId()), SafeArg.of("acquireTimeoutMs", lockAcquireTimeoutMs), UnsafeArg.of("firstTenLockDescriptors", Iterables.limit(lockDescriptors, 10)));
throw new TransactionLockAcquisitionTimeoutException("Timed out waiting for commits to complete.");
}
}
use of com.palantir.atlasdb.transaction.api.TransactionLockAcquisitionTimeoutException in project atlasdb by palantir.
the class SnapshotTransaction method acquireLocksForCommit.
// /////////////////////////////////////////////////////////////////////////
// / Locking
// /////////////////////////////////////////////////////////////////////////
/**
* This method should acquire any locks needed to do proper concurrency control at commit time.
*/
protected LockToken acquireLocksForCommit() {
Set<LockDescriptor> lockDescriptors = getLocksForWrites();
LockRequest request = LockRequest.of(lockDescriptors, lockAcquireTimeoutMs);
LockResponse lockResponse = timelockService.lock(request);
if (!lockResponse.wasSuccessful()) {
log.error("Timed out waiting while acquiring commit locks. Request id was {}. Timeout was {} ms. " + "First ten required locks were {}.", SafeArg.of("requestId", request.getRequestId()), SafeArg.of("acquireTimeoutMs", lockAcquireTimeoutMs), UnsafeArg.of("firstTenLockDescriptors", Iterables.limit(lockDescriptors, 10)));
throw new TransactionLockAcquisitionTimeoutException("Timed out while acquiring commit locks.");
}
return lockResponse.getToken();
}
Aggregations