Search in sources :

Example 1 with UnderlyingStorageException

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);
}
Also used : IOException(java.io.IOException) CountsTracker(org.neo4j.kernel.impl.store.counts.CountsTracker) UnderlyingStorageException(org.neo4j.kernel.impl.store.UnderlyingStorageException)

Example 2 with UnderlyingStorageException

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();
    }
}
Also used : IOException(java.io.IOException) UnderlyingStorageException(org.neo4j.kernel.impl.store.UnderlyingStorageException) IndexEntryConflictException(org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException)

Example 3 with UnderlyingStorageException

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);
    }
}
Also used : UnderlyingStorageException(org.neo4j.kernel.impl.store.UnderlyingStorageException) Groups.checkPoint(org.neo4j.kernel.impl.util.JobScheduler.Groups.checkPoint) Test(org.junit.Test)

Example 4 with UnderlyingStorageException

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);
    }
}
Also used : IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) UnderlyingStorageException(org.neo4j.kernel.impl.store.UnderlyingStorageException)

Example 5 with UnderlyingStorageException

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);
    }
}
Also used : IOException(java.io.IOException) UnderlyingStorageException(org.neo4j.kernel.impl.store.UnderlyingStorageException)

Aggregations

UnderlyingStorageException (org.neo4j.kernel.impl.store.UnderlyingStorageException)13 IOException (java.io.IOException)10 ByteBuffer (java.nio.ByteBuffer)4 Test (org.junit.Test)3 HashSet (java.util.HashSet)2 Map (java.util.Map)2 IndexEntryConflictException (org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException)2 File (java.io.File)1 UncheckedIOException (java.io.UncheckedIOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Set (java.util.Set)1 Function (java.util.function.Function)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 Stream (java.util.stream.Stream)1 Nonnull (javax.annotation.Nonnull)1 Matchers.hasItems (org.hamcrest.Matchers.hasItems)1 Matchers.not (org.hamcrest.Matchers.not)1