use of org.neo4j.kernel.impl.store.kvstore.RotationTimeoutException in project neo4j by neo4j.
the class CountsRotationTest method shouldUnMapThePrestateFileWhenTimingOutOnRotationAndAllowForShutdownInTheFailedRotationState.
@Test
public void shouldUnMapThePrestateFileWhenTimingOutOnRotationAndAllowForShutdownInTheFailedRotationState() throws Throwable {
// Given
dbBuilder.newGraphDatabase().shutdown();
CountsTracker store = createCountsTracker(pageCache, Config.defaults().augment(Collections.singletonMap(GraphDatabaseSettings.counts_store_rotation_timeout.name(), "100ms")));
try (Lifespan lifespan = new Lifespan(store)) {
try (CountsAccessor.Updater updater = store.apply(2).get()) {
updater.incrementNodeCount(0, 1);
}
try {
// when
store.rotate(3);
fail("should have thrown");
} catch (RotationTimeoutException ex) {
// good
}
}
// and also no exceptions closing the page cache
pageCache.close();
}
use of org.neo4j.kernel.impl.store.kvstore.RotationTimeoutException in project neo4j by neo4j.
the class CountsTrackerTest method shouldNotEndUpInBrokenStateAfterRotationFailure.
@Test
@Resources.Life(STARTED)
public void shouldNotEndUpInBrokenStateAfterRotationFailure() throws Exception {
// GIVEN
FakeClock clock = Clocks.fakeClock();
CountsTracker tracker = resourceManager.managed(newTracker(clock));
int labelId = 1;
try (CountsAccessor.Updater tx = tracker.apply(2).get()) {
// now at 1
tx.incrementNodeCount(labelId, 1);
}
// WHEN
Predicate<Thread> arrived = thread -> stackTraceContains(thread, all(classNameContains("Rotation"), methodIs("rotate")));
Future<Object> rotation = threading.executeAndAwait(t -> t.rotate(4), tracker, arrived, 100, MILLISECONDS);
try (CountsAccessor.Updater tx = tracker.apply(3).get()) {
// now at 2
tx.incrementNodeCount(labelId, 1);
}
clock.forward(Config.empty().get(GraphDatabaseSettings.counts_store_rotation_timeout) * 2, MILLISECONDS);
try {
rotation.get();
fail("Should've failed rotation due to timeout");
} catch (ExecutionException e) {
// good
assertTrue(e.getCause() instanceof RotationTimeoutException);
}
// THEN
Register.DoubleLongRegister register = Registers.newDoubleLongRegister();
tracker.get(CountsKeyFactory.nodeKey(labelId), register);
assertEquals(2, register.readSecond());
// and WHEN later attempting rotation again
try (CountsAccessor.Updater tx = tracker.apply(4).get()) {
// now at 3
tx.incrementNodeCount(labelId, 1);
}
tracker.rotate(4);
// THEN
tracker.get(CountsKeyFactory.nodeKey(labelId), register);
assertEquals(3, register.readSecond());
}
Aggregations