use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.
the class RecoveryIT method failRecoveryWithMissingStoreFileAndIdFile.
@Test
void failRecoveryWithMissingStoreFileAndIdFile() throws Exception {
GraphDatabaseAPI database = createDatabase();
generateSomeData(database);
DatabaseLayout layout = database.databaseLayout();
managementService.shutdown();
// Recovery should not be attempted on any store with missing store files, even if other recoverable files are missing as well.
fileSystem.deleteFileOrThrow(layout.nodeStore());
fileSystem.deleteFileOrThrow(layout.idLabelTokenStore());
GraphDatabaseAPI restartedDb = createDatabase();
try {
DatabaseStateService dbStateService = restartedDb.getDependencyResolver().resolveDependency(DatabaseStateService.class);
var failure = dbStateService.causeOfFailure(restartedDb.databaseId());
assertTrue(failure.isPresent());
assertThat(failure.get().getCause()).hasMessageContainingAll("neostore.nodestore.db", "is(are) missing and recovery is not possible");
} finally {
managementService.shutdown();
}
}
use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.
the class RecoveryIT method cancelRecoveryInTheMiddle.
@Test
void cancelRecoveryInTheMiddle() throws Throwable {
GraphDatabaseAPI db = createDatabase();
generateSomeData(db);
DatabaseLayout layout = db.databaseLayout();
managementService.shutdown();
RecoveryHelpers.removeLastCheckpointRecordFromLastLogFile(databaseLayout, fileSystem);
assertTrue(isRecoveryRequired(layout));
Monitors monitors = new Monitors();
var guardExtensionFactory = new GlobalGuardConsumerTestExtensionFactory();
var recoveryMonitor = new RecoveryMonitor() {
private final AtomicBoolean reverseCompleted = new AtomicBoolean();
private final AtomicBoolean recoveryCompleted = new AtomicBoolean();
@Override
public void reverseStoreRecoveryCompleted(long lowestRecoveredTxId) {
try {
guardExtensionFactory.getProvidedGuardConsumer().globalGuard.stop();
} catch (Exception e) {
// do nothing
}
reverseCompleted.set(true);
}
@Override
public void recoveryCompleted(int numberOfRecoveredTransactions, long recoveryTimeInMilliseconds) {
recoveryCompleted.set(true);
}
public boolean isReverseCompleted() {
return reverseCompleted.get();
}
public boolean isRecoveryCompleted() {
return recoveryCompleted.get();
}
};
monitors.addMonitorListener(recoveryMonitor);
var service = new TestDatabaseManagementServiceBuilder(layout.getNeo4jLayout()).addExtension(guardExtensionFactory).setMonitors(monitors).build();
try {
var database = service.database(layout.getDatabaseName());
assertTrue(recoveryMonitor.isReverseCompleted());
assertFalse(recoveryMonitor.isRecoveryCompleted());
assertFalse(guardExtensionFactory.getProvidedGuardConsumer().globalGuard.isAvailable());
assertFalse(database.isAvailable(0));
var e = assertThrows(Exception.class, database::beginTx);
assertThat(getRootCause(e)).isInstanceOf(DatabaseStartAbortedException.class);
} finally {
service.shutdown();
}
}
use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.
the class RecoveryIT method resetCheckpointVersionOnMissingLogFilesWhenValueIsDefinitelyWrong.
@Test
void resetCheckpointVersionOnMissingLogFilesWhenValueIsDefinitelyWrong() throws Exception {
GraphDatabaseAPI db = createDatabase();
generateSomeData(db);
DatabaseLayout layout = db.databaseLayout();
managementService.shutdown();
removeTransactionLogs();
assertTrue(isRecoveryRequired(layout));
MetaDataStore.setRecord(pageCache, layout.metadataStore(), CHECKPOINT_LOG_VERSION, -42, layout.getDatabaseName(), NULL);
recoverDatabase();
assertFalse(isRecoveryRequired(layout));
assertEquals(0, MetaDataStore.getRecord(pageCache, layout.metadataStore(), CHECKPOINT_LOG_VERSION, layout.getDatabaseName(), NULL));
}
use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.
the class RecoveryIT method recoverDatabaseWithoutOneIdFile.
@Test
void recoverDatabaseWithoutOneIdFile() throws Throwable {
GraphDatabaseAPI db = createDatabase();
generateSomeData(db);
DatabaseLayout layout = db.databaseLayout();
managementService.shutdown();
fileSystem.deleteFileOrThrow(layout.idRelationshipStore());
assertTrue(isRecoveryRequired(layout));
performRecovery(fileSystem, pageCache, EMPTY, defaults(), layout, INSTANCE);
assertFalse(isRecoveryRequired(layout));
assertTrue(fileSystem.fileExists(layout.idRelationshipStore()));
}
use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.
the class RecoveryIT method failRecoveryWithMissingStoreFile.
@Test
void failRecoveryWithMissingStoreFile() throws Exception {
GraphDatabaseAPI database = createDatabase();
generateSomeData(database);
DatabaseLayout layout = database.databaseLayout();
managementService.shutdown();
fileSystem.deleteFileOrThrow(layout.nodeStore());
GraphDatabaseAPI restartedDb = createDatabase();
try {
DatabaseStateService dbStateService = restartedDb.getDependencyResolver().resolveDependency(DatabaseStateService.class);
var failure = dbStateService.causeOfFailure(restartedDb.databaseId());
assertTrue(failure.isPresent());
assertThat(failure.get().getCause()).hasMessageContainingAll("neostore.nodestore.db", "is(are) missing and recovery is not possible");
} finally {
managementService.shutdown();
}
}
Aggregations