use of org.neo4j.kernel.impl.store.UnderlyingStorageException in project neo4j by neo4j.
the class BatchInserterImpl method rebuildCounts.
private void rebuildCounts() {
CountsTracker counts = neoStores.getCounts();
try {
counts.start();
} catch (IOException e) {
throw new UnderlyingStorageException(e);
}
CountsComputer.recomputeCounts(neoStores);
}
use of org.neo4j.kernel.impl.store.UnderlyingStorageException in project neo4j by neo4j.
the class BatchInserterImpl method shutdown.
@Override
public void shutdown() {
if (isShutdown) {
throw new IllegalStateException("Batch inserter already has shutdown");
}
isShutdown = true;
flushStrategy.forceFlush();
rebuildCounts();
try {
repopulateAllIndexes();
} catch (IOException | IndexEntryConflictException e) {
throw new RuntimeException(e);
} finally {
cursors.close();
neoStores.close();
try {
storeLocker.close();
} catch (IOException e) {
throw new UnderlyingStorageException("Could not release store lock", e);
}
msgLog.info(Thread.currentThread() + " Clean shutdown on BatchInserter(" + this + ")", true);
life.shutdown();
}
}
use of org.neo4j.kernel.impl.store.UnderlyingStorageException in project neo4j by neo4j.
the class CheckPointSchedulerTest method shouldCausePanicAfterSomeFailures.
@Test
public void shouldCausePanicAfterSomeFailures() throws Throwable {
// GIVEN
RuntimeException[] failures = new RuntimeException[] { new RuntimeException("First"), new RuntimeException("Second"), new RuntimeException("Third") };
when(checkPointer.checkPointIfNeeded(any(TriggerInfo.class))).thenThrow(failures);
CheckPointScheduler scheduler = new CheckPointScheduler(checkPointer, jobScheduler, 1, health);
scheduler.start();
// WHEN
for (int i = 0; i < CheckPointScheduler.MAX_CONSECUTIVE_FAILURES_TOLERANCE - 1; i++) {
jobScheduler.runJob();
verifyZeroInteractions(health);
}
try {
jobScheduler.runJob();
fail("Should have failed");
} catch (UnderlyingStorageException e) {
// THEN
assertEquals(Iterators.asSet(failures), Iterators.asSet(e.getSuppressed()));
verify(health).panic(e);
}
}
use of org.neo4j.kernel.impl.store.UnderlyingStorageException in project neo4j by neo4j.
the class NativeLabelScanStore method force.
/**
* Forces all changes to {@link PageCache} and creates a checkpoint so that the {@link LabelScanStore}
* is recoverable from this point, given that the same transactions which will be applied after this point
* and non-clean shutdown will be applied again on next startup.
*
* @param limiter {@link IOLimiter}.
* @throws UnderlyingStorageException on failure writing changes to {@link PageCache}.
*/
@Override
public void force(IOLimiter limiter) throws UnderlyingStorageException {
try {
maybeCompleteRecovery();
index.checkpoint(limiter);
} catch (IOException e) {
throw new UnderlyingStorageException(e);
}
}
use of org.neo4j.kernel.impl.store.UnderlyingStorageException in project neo4j by neo4j.
the class FreeIdKeeper method writeIdBatch.
/*
* writes to disk, after the current channel.position(), the contents of the freeIds list. If aggressiveReuse
* is set, it will also forward the maxReadPosition to the end of the file.
*/
private void writeIdBatch(ByteBuffer writeBuffer) {
try {
// position at end
positionChannel(channel.size());
writeBuffer.clear();
while (!freeIds.isEmpty()) {
long id = freeIds.removeFirst();
if (id == NO_RESULT) {
continue;
}
writeBuffer.putLong(id);
if (writeBuffer.position() == writeBuffer.capacity()) {
writeBuffer.flip();
while (writeBuffer.hasRemaining()) {
channel.write(writeBuffer);
}
writeBuffer.clear();
}
}
writeBuffer.flip();
while (writeBuffer.hasRemaining()) {
channel.write(writeBuffer);
}
if (aggressiveReuse) {
maxReadPosition = channel.size();
}
} catch (IOException e) {
throw new UnderlyingStorageException("Unable to write defragged id " + " batch", e);
}
}
Aggregations