use of org.neo4j.com.ComException in project neo4j by neo4j.
the class PropertyConstraintsStressIT method performInserts.
/**
* Inserts a bunch of new nodes with the label and property key currently set in the fields in this class, where
* running this method twice will insert nodes with duplicate property values, assuming property key or label has
* not changed.
*/
private WorkerCommand<Object, Integer> performInserts(final HighlyAvailableGraphDatabase slave, final boolean constraintCompliant) {
return new WorkerCommand<Object, Integer>() {
@Override
public Integer doWork(Object state) throws Exception {
int i = 0;
try {
for (; i < 100; i++) {
try (Transaction tx = slave.beginTx()) {
constraintOps.createEntity(slave, labelOrRelType, property, "value" + i, constraintCompliant);
tx.success();
}
}
} catch (TransactionFailureException | TransientTransactionFailureException e) {
// Swallowed on purpose, we except it to fail sometimes due to either
// - constraint violation on master
// - concurrent schema operation on master
} catch (ConstraintViolationException e) {
// Constraint violation detected on slave while building transaction
} catch (ComException e) {
// Happens sometimes, cause:
// - The lock session requested to start is already in use.
// Please retry your request in a few seconds.
}
return i;
}
};
}
use of org.neo4j.com.ComException in project neo4j by neo4j.
the class SlaveTokenCreatorTest method mustTranslateComExceptionsToTransientTransactionFailures.
@Test(expected = TransientTransactionFailureException.class)
public void mustTranslateComExceptionsToTransientTransactionFailures() throws Exception {
when(fixture.callMasterMethod(master, requestContext, name)).thenThrow(new ComException());
tokenCreator.getOrCreate(name);
}
use of org.neo4j.com.ComException in project neo4j by neo4j.
the class SlaveTransactionCommitProcessTest method mustTranslateComExceptionsToTransientTransactionFailures.
@Test(expected = TransientTransactionFailureException.class)
public void mustTranslateComExceptionsToTransientTransactionFailures() throws Exception {
when(master.commit(requestContext, tx)).thenThrow(new ComException());
// When
commitProcess.commit(new TransactionToApply(tx), CommitEvent.NULL, TransactionApplicationMode.INTERNAL);
// Then we assert that the right exception is thrown
}
use of org.neo4j.com.ComException in project neo4j by neo4j.
the class SlaveUpdatePullerTest method shouldCapExcessiveComExceptionLogging.
@Test
public void shouldCapExcessiveComExceptionLogging() throws Exception {
OngoingStubbing<Response<Void>> updatePullStubbing = when(master.pullUpdates(any(RequestContext.class)));
updatePullStubbing.thenThrow(new ComException());
for (int i = 0; i < SlaveUpdatePuller.LOG_CAP + 20; i++) {
updatePuller.pullUpdates();
}
logProvider.assertContainsThrowablesMatching(0, repeat(new ComException(), SlaveUpdatePuller.LOG_CAP));
// And we should be able to recover afterwards
updatePullStubbing.thenReturn(Response.EMPTY).thenThrow(new ComException());
// This one will succeed and unlock the circuit breaker
updatePuller.pullUpdates();
// And then we log another exception
updatePuller.pullUpdates();
logProvider.assertContainsThrowablesMatching(0, repeat(new ComException(), SlaveUpdatePuller.LOG_CAP + 1));
}
use of org.neo4j.com.ComException in project graphdb by neo4j-attic.
the class TestBackup method makeSureStoreIdIsEnforced.
@Test
public void makeSureStoreIdIsEnforced() throws Exception {
// Create data set X on server A
DbRepresentation initialDataSetRepresentation = createInitialDataSet(serverPath);
ServerInterface server = startServer(serverPath);
// Grab initial backup from server A
OnlineBackup backup = OnlineBackup.from("localhost");
backup.full(backupPath);
assertEquals(initialDataSetRepresentation, DbRepresentation.of(backupPath));
shutdownServer(server);
// Create data set X+Y on server B
createInitialDataSet(otherServerPath);
addMoreData(otherServerPath);
server = startServer(otherServerPath);
// Data should be OK, but store id check should prevent that.
try {
backup.incremental(backupPath);
fail("Shouldn't work");
} catch (ComException e) {
// Good
}
shutdownServer(server);
// Just make sure incremental backup can be received properly from
// server A, even after a failed attempt from server B
DbRepresentation furtherRepresentation = addMoreData(serverPath);
server = startServer(serverPath);
backup.incremental(backupPath);
assertEquals(furtherRepresentation, DbRepresentation.of(backupPath));
shutdownServer(server);
}
Aggregations