use of org.neo4j.kernel.impl.transaction.log.files.LogFiles in project neo4j by neo4j.
the class RecoveryIT method countCheckPointsInTransactionLogs.
private int countCheckPointsInTransactionLogs() throws IOException {
LogFiles logFiles = buildLogFiles();
var checkpoints = logFiles.getCheckpointFile().reachableCheckpoints();
return checkpoints.size();
}
use of org.neo4j.kernel.impl.transaction.log.files.LogFiles in project neo4j by neo4j.
the class LogPruningIT method pruningStrategyShouldBeDynamic.
@Test
void pruningStrategyShouldBeDynamic() throws IOException {
LogFiles logFiles = LogFilesBuilder.builder(db.databaseLayout(), fs).withLogVersionRepository(new SimpleLogVersionRepository()).withLastCommittedTransactionIdSupplier(() -> 1).withCommandReaderFactory(db.getDependencyResolver().resolveDependency(StorageEngineFactory.class).commandReaderFactory()).withTransactionIdStore(new SimpleTransactionIdStore()).build();
// Force transaction log rotation
writeTransactionsAndRotateTwice();
// Checkpoint to make sure strategy is evaluated
checkPointer.forceCheckPoint(triggerInfo);
// Make sure file is still there since we have disable pruning. 3 transaction logs and 1 separate checkpoint file.
assertThat(countTransactionLogs(logFiles)).isEqualTo(4);
// Change pruning to true
config.setDynamic(keep_logical_logs, FALSE, "LogPruningIT");
// Checkpoint to make sure strategy is evaluated
checkPointer.forceCheckPoint(triggerInfo);
// Make sure file is removed
assertThat(countTransactionLogs(logFiles)).isEqualTo(3);
}
use of org.neo4j.kernel.impl.transaction.log.files.LogFiles in project neo4j by neo4j.
the class MissingStoreFilesRecoveryIT method failToStartOnMissingFilesAndPartialTransactionLogs.
@Test
void failToStartOnMissingFilesAndPartialTransactionLogs() throws IOException {
LogFiles logFiles = prepareDatabaseWithTwoTxLogFiles();
fileSystem.deleteFile(logFiles.getLogFile().getLogFileForVersion(0));
fileSystem.deleteFile(databaseLayout.nodeStore());
var dbStateService = getDatabaseStateService();
var failure = dbStateService.causeOfFailure(defaultNamedDatabaseId);
assertFalse(failure.isPresent());
assertFalse(fileSystem.fileExists(databaseLayout.nodeStore()));
}
use of org.neo4j.kernel.impl.transaction.log.files.LogFiles in project neo4j by neo4j.
the class MissingStoreFilesRecoveryIT method rotateTransactionLogs.
private static LogFiles rotateTransactionLogs(GraphDatabaseAPI databaseApi) throws IOException {
LogFiles logFiles = databaseApi.getDependencyResolver().resolveDependency(LogFiles.class);
LogFile logFile = logFiles.getLogFile();
logFile.rotate();
return logFiles;
}
use of org.neo4j.kernel.impl.transaction.log.files.LogFiles in project neo4j by neo4j.
the class Runner method call.
@Override
public Long call() throws Exception {
long lastCommittedTransactionId;
try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
Lifespan life = new Lifespan()) {
TransactionIdStore transactionIdStore = new SimpleTransactionIdStore();
TransactionMetadataCache transactionMetadataCache = new TransactionMetadataCache();
LogFiles logFiles = life.add(createLogFiles(transactionIdStore, fileSystem));
TransactionAppender transactionAppender = life.add(createBatchingTransactionAppender(transactionIdStore, transactionMetadataCache, logFiles));
ExecutorService executorService = Executors.newFixedThreadPool(threads);
try {
List<Future<?>> handlers = new ArrayList<>(threads);
for (int i = 0; i < threads; i++) {
TransactionRepresentationFactory factory = new TransactionRepresentationFactory();
Worker task = new Worker(transactionAppender, factory, condition);
handlers.add(executorService.submit(task));
}
// wait for all the workers to complete
Futures.getAll(handlers);
} finally {
executorService.shutdown();
}
lastCommittedTransactionId = transactionIdStore.getLastCommittedTransactionId();
}
return lastCommittedTransactionId;
}
Aggregations