use of org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore 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.SimpleTransactionIdStore 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;
}
use of org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore 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.SimpleTransactionIdStore 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.SimpleTransactionIdStore in project neo4j by neo4j.
the class VersionAwareLogEntryReaderIT method correctlyResetPositionWhenEndOfCommandsReached.
@Test
void correctlyResetPositionWhenEndOfCommandsReached() throws IOException {
LogFiles logFiles = LogFilesBuilder.builder(databaseLayout, fs).withLogEntryReader(entryReader).withLogVersionRepository(new SimpleLogVersionRepository()).withTransactionIdStore(new SimpleTransactionIdStore()).withStoreId(StoreId.UNKNOWN).build();
try (Lifespan lifespan = new Lifespan(logFiles)) {
LogPosition logPosition = entryReader.lastPosition();
assertEquals(0L, logPosition.getLogVersion());
// this position in a log file before 0's are actually starting
assertEquals(END_OF_DATA_OFFSET, logPosition.getByteOffset());
for (int i = 0; i < 10; i++) {
assertEquals(END_OF_DATA_OFFSET, getLastReadablePosition(logFiles));
}
}
}
Aggregations