use of org.neo4j.kernel.impl.transaction.log.files.LogFiles in project neo4j by neo4j.
the class DumpCommandIT method databaseThatRequireRecoveryIsNotDumpable.
@Test
void databaseThatRequireRecoveryIsNotDumpable() throws IOException {
LogFiles logFiles = LogFilesBuilder.builder(databaseLayout, testDirectory.getFileSystem()).withLogVersionRepository(new SimpleLogVersionRepository()).withTransactionIdStore(new SimpleTransactionIdStore()).withCommandReaderFactory(StorageEngineFactory.defaultStorageEngine().commandReaderFactory()).withStoreId(StoreId.UNKNOWN).build();
try (Lifespan ignored = new Lifespan(logFiles)) {
LogFile logFile = logFiles.getLogFile();
LogEntryWriter writer = logFile.getTransactionLogWriter().getWriter();
writer.writeStartEntry(0x123456789ABCDEFL, logFile.getLogFileInformation().getLastEntryId() + 1, BASE_TX_CHECKSUM, new byte[] { 0 });
}
CommandFailedException commandFailed = assertThrows(CommandFailedException.class, () -> execute("foo"));
assertThat(commandFailed.getMessage()).startsWith("Active logical log detected, this might be a source of inconsistencies.");
}
use of org.neo4j.kernel.impl.transaction.log.files.LogFiles in project neo4j by neo4j.
the class MissingStoreFilesRecoveryIT method prepareDatabaseWithTwoTxLogFiles.
private LogFiles prepareDatabaseWithTwoTxLogFiles() throws IOException {
managementService = serviceBuilder.build();
var databaseApi = defaultDatabase(managementService);
LogFiles logFiles = rotateTransactionLogs(databaseApi);
assertNotNull(logFiles.getLogFile().getLogFileForVersion(1));
createSomeData(databaseApi);
managementService.shutdown();
return logFiles;
}
use of org.neo4j.kernel.impl.transaction.log.files.LogFiles in project neo4j by neo4j.
the class RecoveryCorruptedTransactionLogIT method generateTransactionsAndRotate.
private static void generateTransactionsAndRotate(GraphDatabaseAPI database, int logFilesToGenerate, boolean checkpoint) throws IOException {
DependencyResolver resolver = database.getDependencyResolver();
LogFiles logFiles = resolver.resolveDependency(LogFiles.class);
CheckPointer checkpointer = resolver.resolveDependency(CheckPointer.class);
while (logFiles.getLogFile().getHighestLogVersion() < logFilesToGenerate) {
logFiles.getLogFile().rotate();
generateTransaction(database);
if (checkpoint) {
checkpointer.forceCheckPoint(new SimpleTriggerInfo("testForcedCheckpoint"));
}
}
}
use of org.neo4j.kernel.impl.transaction.log.files.LogFiles in project neo4j by neo4j.
the class RecoveryCorruptedTransactionLogIT method addCorruptedCommandsToLastLogFile.
private void addCorruptedCommandsToLastLogFile(LogEntryWriterWrapper logEntryWriterWrapper) throws IOException {
PositiveLogFilesBasedLogVersionRepository versionRepository = new PositiveLogFilesBasedLogVersionRepository(logFiles);
LogFiles internalLogFiles = LogFilesBuilder.builder(databaseLayout, fileSystem).withLogVersionRepository(versionRepository).withTransactionIdStore(new SimpleTransactionIdStore()).withStoreId(StoreId.UNKNOWN).withCommandReaderFactory(StorageEngineFactory.defaultStorageEngine().commandReaderFactory()).build();
try (Lifespan lifespan = new Lifespan(internalLogFiles)) {
LogFile transactionLogFile = internalLogFiles.getLogFile();
LogEntryWriter<FlushablePositionAwareChecksumChannel> realLogEntryWriter = transactionLogFile.getTransactionLogWriter().getWriter();
LogEntryWriter<FlushablePositionAwareChecksumChannel> wrappedLogEntryWriter = logEntryWriterWrapper.wrap(realLogEntryWriter);
StaticLogEntryWriterFactory<FlushablePositionAwareChecksumChannel> factory = new StaticLogEntryWriterFactory<>(wrappedLogEntryWriter);
TransactionLogWriter writer = new TransactionLogWriter(realLogEntryWriter.getChannel(), factory);
List<StorageCommand> commands = new ArrayList<>();
commands.add(new Command.PropertyCommand(new PropertyRecord(1), new PropertyRecord(2)));
commands.add(new Command.NodeCommand(new NodeRecord(2), new NodeRecord(3)));
PhysicalTransactionRepresentation transaction = new PhysicalTransactionRepresentation(commands);
transaction.setHeader(new byte[0], 0, 0, 0, 0, ANONYMOUS);
writer.append(transaction, 1000, BASE_TX_CHECKSUM);
}
}
use of org.neo4j.kernel.impl.transaction.log.files.LogFiles in project neo4j by neo4j.
the class LogVersionUpgradeCheckerIT method appendCheckpoint.
private void appendCheckpoint(byte logEntryVersion, boolean removeCheckpointFile) throws IOException {
VersionAwareLogEntryReader logEntryReader = new VersionAwareLogEntryReader(StorageEngineFactory.defaultStorageEngine().commandReaderFactory());
LogFiles logFiles = LogFilesBuilder.activeFilesBuilder(databaseLayout, fileSystem, pageCache).withLogEntryReader(logEntryReader).withStoreId(StoreId.UNKNOWN).build();
if (removeCheckpointFile) {
for (Path file : fileSystem.listFiles(logFiles.logFilesDirectory(), path -> path.getFileName().toString().startsWith(CHECKPOINT_FILE_PREFIX))) {
fileSystem.deleteFile(file);
}
}
try (Lifespan lifespan = new Lifespan(logFiles)) {
LogFile logFile = logFiles.getLogFile();
TransactionLogWriter transactionLogWriter = logFile.getTransactionLogWriter();
var channel = transactionLogWriter.getChannel();
LogPosition logPosition = transactionLogWriter.getCurrentPosition();
// Fake record
channel.put(logEntryVersion).put(LEGACY_CHECK_POINT).putLong(logPosition.getLogVersion()).putLong(logPosition.getByteOffset());
logFile.flush();
}
}
Aggregations