use of org.neo4j.exceptions.UnderlyingStorageException in project neo4j by neo4j.
the class IndexUpdaterMap method close.
@Override
public void close() throws UnderlyingStorageException {
Set<Pair<IndexDescriptor, UnderlyingStorageException>> exceptions = null;
for (Map.Entry<IndexDescriptor, IndexUpdater> updaterEntry : updaterMap.entrySet()) {
IndexUpdater updater = updaterEntry.getValue();
try {
updater.close();
} catch (UncheckedIOException | IndexEntryConflictException e) {
if (null == exceptions) {
exceptions = new HashSet<>();
}
exceptions.add(Pair.of(updaterEntry.getKey(), new UnderlyingStorageException(e)));
}
}
clear();
if (null != exceptions) {
throw new MultipleUnderlyingStorageExceptions(exceptions);
}
}
use of org.neo4j.exceptions.UnderlyingStorageException in project neo4j by neo4j.
the class RecoveryStartInformationProvider method get.
/**
* Find the log position to start recovery from
*
* @return {@link LogPosition#UNSPECIFIED} if there is no need to recover otherwise the {@link LogPosition} to
* start recovery from
* @throws IOException if log files cannot be read
*/
@Override
public RecoveryStartInformation get() {
LogTailInformation logTailInformation = logFiles.getTailInformation();
CheckpointInfo lastCheckPoint = logTailInformation.lastCheckPoint;
long txIdAfterLastCheckPoint = logTailInformation.firstTxIdAfterLastCheckPoint;
if (!logTailInformation.isRecoveryRequired()) {
monitor.noCommitsAfterLastCheckPoint(lastCheckPoint != null ? lastCheckPoint.getTransactionLogPosition() : null);
return NO_RECOVERY_REQUIRED;
}
if (logTailInformation.logsMissing()) {
return MISSING_LOGS;
}
if (logTailInformation.commitsAfterLastCheckpoint()) {
if (lastCheckPoint == null) {
long lowestLogVersion = logFiles.getLogFile().getLowestLogVersion();
if (lowestLogVersion != INITIAL_LOG_VERSION) {
throw new UnderlyingStorageException("No check point found in any log file from version " + lowestLogVersion + " to " + logTailInformation.currentLogVersion);
}
monitor.noCheckPointFound();
LogPosition position = tryExtractHeaderSize();
return createRecoveryInformation(position, new LogPosition(INITIAL_LOG_VERSION, CURRENT_FORMAT_LOG_HEADER_SIZE), txIdAfterLastCheckPoint);
}
LogPosition transactionLogPosition = lastCheckPoint.getTransactionLogPosition();
monitor.commitsAfterLastCheckPoint(transactionLogPosition, txIdAfterLastCheckPoint);
return createRecoveryInformation(transactionLogPosition, lastCheckPoint.getCheckpointEntryPosition(), txIdAfterLastCheckPoint);
} else {
throw new UnderlyingStorageException("Fail to determine recovery information Log tail info: " + logTailInformation);
}
}
use of org.neo4j.exceptions.UnderlyingStorageException in project neo4j by neo4j.
the class RecoveryStartInformationProviderTest method shouldFailIfThereAreNoCheckPointsAndOldestLogVersionInNotZero.
@Test
void shouldFailIfThereAreNoCheckPointsAndOldestLogVersionInNotZero() {
// given
long oldestLogVersionFound = 1L;
when(logFile.getLowestLogVersion()).thenReturn(oldestLogVersionFound);
when(logFiles.getTailInformation()).thenReturn(new LogTailInformation(true, 10L, false, currentLogVersion, LATEST.version()));
// when
UnderlyingStorageException storageException = assertThrows(UnderlyingStorageException.class, () -> new RecoveryStartInformationProvider(logFiles, monitor).get());
final String expectedMessage = "No check point found in any log file from version " + oldestLogVersionFound + " to " + logVersion;
assertEquals(expectedMessage, storageException.getMessage());
}
use of org.neo4j.exceptions.UnderlyingStorageException in project neo4j by neo4j.
the class CommonAbstractStore method flush.
@Override
public void flush(CursorContext cursorContext) {
try {
pagedFile.flushAndForce();
idGenerator.checkpoint(cursorContext);
} catch (IOException e) {
throw new UnderlyingStorageException("Failed to flush", e);
}
}
use of org.neo4j.exceptions.UnderlyingStorageException in project neo4j by neo4j.
the class CommonAbstractStore method updateRecord.
@Override
public void updateRecord(RECORD record, IdUpdateListener idUpdateListener, PageCursor cursor, CursorContext cursorContext) {
long id = record.getId();
IdValidator.assertValidId(getIdType(), id, recordFormat.getMaxId());
long pageId = pageIdForRecord(id);
int offset = offsetForId(id);
try {
if (cursor.next(pageId)) {
cursor.setOffset(offset);
recordFormat.write(record, cursor, recordSize, recordsPerPage);
// We don't free ids if something weird goes wrong
checkForDecodingErrors(cursor, id, NORMAL);
if (!record.inUse()) {
idUpdateListener.markIdAsUnused(idType, idGenerator, id, cursorContext);
} else if (record.isCreated()) {
idUpdateListener.markIdAsUsed(idType, idGenerator, id, cursorContext);
}
if ((!record.inUse() || !record.requiresSecondaryUnit()) && record.hasSecondaryUnitId()) {
// If record was just now deleted, or if the record used a secondary unit, but not anymore
// then free the id of that secondary unit.
idUpdateListener.markIdAsUnused(idType, idGenerator, record.getSecondaryUnitId(), cursorContext);
}
if (record.inUse() && record.isSecondaryUnitCreated()) {
// Triggers on:
// - (a) record got created right now and has a secondary unit, or
// - (b) it already existed and just now grew into a secondary unit then mark the secondary unit as used
idUpdateListener.markIdAsUsed(idType, idGenerator, record.getSecondaryUnitId(), cursorContext);
}
}
} catch (IOException e) {
throw new UnderlyingStorageException(e);
}
}
Aggregations