use of org.neo4j.kernel.impl.util.collection.ConcurrentAccessException in project neo4j by neo4j.
the class MasterImpl method newLockSession.
@Override
public Response<Void> newLockSession(RequestContext context) throws TransactionFailureException {
monitor.initializeTx(context);
if (!spi.isAccessible()) {
throw new TransactionFailureException(Status.General.DatabaseUnavailable, "Database is currently not available");
}
assertCorrectEpoch(context);
try {
conversationManager.begin(context);
} catch (ConcurrentAccessException e) {
throw new TransactionFailureException(Status.Transaction.TransactionAccessedConcurrently, e, "The lock session requested to start is already in use. " + "Please retry your request in a few seconds.");
}
return spi.packTransactionObligationResponse(context, null);
}
use of org.neo4j.kernel.impl.util.collection.ConcurrentAccessException in project neo4j by neo4j.
the class MasterImpl method acquireExclusiveLock.
@Override
public Response<LockResult> acquireExclusiveLock(RequestContext context, ResourceType type, long... resourceIds) {
assertCorrectEpoch(context);
Locks.Client session;
try {
session = conversationManager.acquire(context).getLocks();
} catch (NoSuchEntryException | ConcurrentAccessException e) {
return spi.packTransactionObligationResponse(context, new LockResult(LockStatus.NOT_LOCKED, "Unable to acquire exclusive lock: " + e.getMessage()));
}
try {
for (long resourceId : resourceIds) {
session.acquireExclusive(LockTracer.NONE, type, resourceId);
}
return spi.packTransactionObligationResponse(context, new LockResult(LockStatus.OK_LOCKED));
} catch (DeadlockDetectedException e) {
return spi.packTransactionObligationResponse(context, new LockResult(LockStatus.DEAD_LOCKED, "Can't acquire exclusive lock, because it would have caused a deadlock: " + e.getMessage()));
} catch (IllegalResourceException e) {
return spi.packTransactionObligationResponse(context, new LockResult(LockStatus.NOT_LOCKED, "Attempted to lock illegal resource: " + e.getMessage()));
} finally {
conversationManager.release(context);
}
}
use of org.neo4j.kernel.impl.util.collection.ConcurrentAccessException in project neo4j by neo4j.
the class MasterImpl method commit.
@Override
public Response<Long> commit(RequestContext context, TransactionRepresentation preparedTransaction) throws IOException, org.neo4j.kernel.api.exceptions.TransactionFailureException {
assertCorrectEpoch(context);
if (context.getEventIdentifier() == Locks.Client.NO_LOCK_SESSION_ID) {
// Client is not holding locks, use a temporary lock client
try (Conversation conversation = conversationManager.acquire()) {
return commit0(context, preparedTransaction, conversation.getLocks());
}
} else {
// Client is holding locks, use the clients lock session
try {
Conversation conversation = conversationManager.acquire(context);
Locks.Client locks = conversation.getLocks();
try {
return commit0(context, preparedTransaction, locks);
} finally {
conversationManager.release(context);
}
} catch (NoSuchEntryException | ConcurrentAccessException e) {
throw new TransactionNotPresentOnMasterException(context);
}
}
}
use of org.neo4j.kernel.impl.util.collection.ConcurrentAccessException in project neo4j by neo4j.
the class MasterImpl method acquireSharedLock.
@Override
public Response<LockResult> acquireSharedLock(RequestContext context, ResourceType type, long... resourceIds) {
assertCorrectEpoch(context);
Locks.Client session;
try {
session = conversationManager.acquire(context).getLocks();
} catch (NoSuchEntryException | ConcurrentAccessException e) {
return spi.packTransactionObligationResponse(context, new LockResult(LockStatus.NOT_LOCKED, "Unable to acquire shared lock: " + e.getMessage()));
}
try {
for (long resourceId : resourceIds) {
session.acquireShared(LockTracer.NONE, type, resourceId);
}
return spi.packTransactionObligationResponse(context, new LockResult(LockStatus.OK_LOCKED));
} catch (DeadlockDetectedException e) {
return spi.packTransactionObligationResponse(context, new LockResult(LockStatus.DEAD_LOCKED, e.getMessage()));
} catch (IllegalResourceException e) {
return spi.packTransactionObligationResponse(context, new LockResult(LockStatus.NOT_LOCKED, "Attempted to lock illegal resource: " + e.getMessage()));
} finally {
conversationManager.release(context);
}
}
Aggregations