use of org.neo4j.kernel.api.exceptions.TransactionFailureException in project neo4j by neo4j.
the class TransitionalTxManagementKernelTransaction method rollback.
public void rollback() {
try {
KernelTransaction kernelTransactionBoundToThisThread = bridge.getKernelTransactionBoundToThisThread(false);
kernelTransactionBoundToThisThread.failure();
kernelTransactionBoundToThisThread.close();
} catch (TransactionFailureException e) {
throw new RuntimeException(e);
} finally {
bridge.unbindTransactionFromCurrentThread();
}
}
use of org.neo4j.kernel.api.exceptions.TransactionFailureException in project neo4j by neo4j.
the class SlaveTransactionCommitProcess method commit.
@Override
public long commit(TransactionToApply batch, CommitEvent commitEvent, TransactionApplicationMode mode) throws TransactionFailureException {
if (batch.next() != null) {
throw new IllegalArgumentException("Only supports single-commit on slave --> master");
}
try {
TransactionRepresentation representation = batch.transactionRepresentation();
RequestContext context = requestContextFactory.newRequestContext(representation.getLockSessionId());
try (Response<Long> response = master.commit(context, representation)) {
return response.response();
}
} catch (IOException e) {
throw new TransactionFailureException(Status.Transaction.TransactionCommitFailed, e, "Could not commit transaction on the master");
} catch (ComException e) {
throw new TransientTransactionFailureException("Cannot commit this transaction on the master. " + "The master is either down, or we have network connectivity problems.", e);
}
}
use of org.neo4j.kernel.api.exceptions.TransactionFailureException in project neo4j by neo4j.
the class ReplicatedTokenStateMachine method applyToStore.
private int applyToStore(Collection<StorageCommand> commands, long logIndex) throws NoSuchEntryException {
int tokenId = extractTokenId(commands);
PhysicalTransactionRepresentation representation = new PhysicalTransactionRepresentation(commands);
representation.setHeader(encodeLogIndexAsTxHeader(logIndex), 0, 0, 0, 0L, 0L, 0);
try (LockGroup ignored = new LockGroup()) {
commitProcess.commit(new TransactionToApply(representation), CommitEvent.NULL, TransactionApplicationMode.EXTERNAL);
} catch (TransactionFailureException e) {
throw new RuntimeException(e);
}
return tokenId;
}
use of org.neo4j.kernel.api.exceptions.TransactionFailureException in project neo4j by neo4j.
the class Rollback method exec.
@Override
protected Continuation exec(AppCommandParser parser, Session session, Output out) throws ShellException, RemoteException {
if (parser.getLineWithoutApp().trim().length() > 0) {
out.println("Error: ROLLBACK should be run without trailing arguments");
return Continuation.INPUT_COMPLETE;
}
KernelTransaction tx = Begin.currentTransaction(getServer());
if (tx == null) {
throw Commit.fail(session, "Not in a transaction");
}
session.remove(Variables.TX_COUNT);
tx.failure();
try {
tx.close();
} catch (TransactionFailureException e) {
throw new ShellException(e.getMessage());
}
out.println("Transaction rolled back");
return Continuation.INPUT_COMPLETE;
}
use of org.neo4j.kernel.api.exceptions.TransactionFailureException in project neo4j by neo4j.
the class SlaveLocksClientTest method mustThrowIfStartingNewLockSessionOnMasterThrowsTransactionFailureException.
@Test(expected = DistributedLockFailureException.class)
public void mustThrowIfStartingNewLockSessionOnMasterThrowsTransactionFailureException() throws Exception {
when(master.newLockSession(any(RequestContext.class))).thenThrow(new TransactionFailureException(Status.General.DatabaseUnavailable, "Not now"));
client.acquireShared(LockTracer.NONE, NODE, 1);
}
Aggregations