use of org.neo4j.kernel.database.Database in project neo4j by neo4j.
the class TransactionRangeDiagnosticsTest method shouldLogNoCheckpointFoundForEmptyPresentCheckpointLog.
@Test
void shouldLogNoCheckpointFoundForEmptyPresentCheckpointLog() throws IOException {
// GIVEN
Database database = databaseWithLogFilesContainingLowestTxId(logs(transactionLogs -> {
}, checkpointLogsWithLastCheckpoint(0, 0, null)));
AssertableLogProvider logProvider = new AssertableLogProvider();
Log logger = logProvider.getLog(getClass());
// WHEN
new TransactionRangeDiagnostics(database).dump(logger::info);
// THEN
assertThat(logProvider).containsMessages("no transactions found").containsMessages("existing checkpoint log versions 0-0").containsMessages("no checkpoints found");
}
use of org.neo4j.kernel.database.Database in project neo4j by neo4j.
the class TransactionRangeDiagnosticsTest method shouldLogCorrectTransactionLogDiagnosticsForTransactionsInSecondOldestLog.
@Test
void shouldLogCorrectTransactionLogDiagnosticsForTransactionsInSecondOldestLog() throws Exception {
// GIVEN
long logVersion = 2;
long prevLogLastTxId = 45;
Database database = databaseWithLogFilesContainingLowestTxId(logWithTransactionsInNextToOldestLog(logVersion, prevLogLastTxId));
AssertableLogProvider logProvider = new AssertableLogProvider();
Log logger = logProvider.getLog(getClass());
// WHEN
new TransactionRangeDiagnostics(database).dump(logger::info);
// THEN
assertThat(logProvider).containsMessages("oldest transaction " + (prevLogLastTxId + 1), "version " + (logVersion + 1)).containsMessages("no checkpoints found");
}
use of org.neo4j.kernel.database.Database in project neo4j by neo4j.
the class TransactionRangeDiagnosticsTest method shouldLogCorrectTransactionLogDiagnosticsForTransactionsInOldestLog.
@Test
void shouldLogCorrectTransactionLogDiagnosticsForTransactionsInOldestLog() throws Exception {
// GIVEN
long logVersion = 2;
long prevLogLastTxId = 45;
Database database = databaseWithLogFilesContainingLowestTxId(logWithTransactions(logVersion, logVersion, prevLogLastTxId));
AssertableLogProvider logProvider = new AssertableLogProvider();
Log logger = logProvider.getLog(getClass());
// WHEN
new TransactionRangeDiagnostics(database).dump(logger::info);
// THEN
assertThat(logProvider).containsMessages("oldest transaction " + (prevLogLastTxId + 1), "version " + logVersion).containsMessages("existing transaction log versions ").containsMessages("no checkpoints found");
}
use of org.neo4j.kernel.database.Database in project neo4j by neo4j.
the class TransactionRangeDiagnosticsTest method databaseWithLogFilesContainingLowestTxId.
private static Database databaseWithLogFilesContainingLowestTxId(LogFiles files) {
Dependencies dependencies = mock(Dependencies.class);
when(dependencies.resolveDependency(LogFiles.class)).thenReturn(files);
Database database = mock(Database.class);
when(database.getDependencyResolver()).thenReturn(dependencies);
return database;
}
use of org.neo4j.kernel.database.Database in project neo4j by neo4j.
the class DefaultDatabaseManager method upgradeDatabase.
@Override
public synchronized void upgradeDatabase(NamedDatabaseId namedDatabaseId) throws DatabaseNotFoundException {
StandaloneDatabaseContext context = getDatabaseContext(namedDatabaseId).orElseThrow(() -> new DatabaseNotFoundException("Database not found: " + namedDatabaseId));
Database database = context.database();
log.info("Upgrading '%s'.", namedDatabaseId);
// Clear any failed state, e.g. due to format being too old on startup.
context.fail(null);
try {
database.upgrade(true);
} catch (Throwable throwable) {
String message = "Failed to upgrade " + namedDatabaseId;
context.fail(throwable);
throw new DatabaseManagementException(message, throwable);
}
}
Aggregations