use of org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore in project neo4j by neo4j.
the class VersionAwareLogEntryReaderIT method readOnlyLogFilesWhileCommandsAreAvailable.
@Test
@EnabledOnOs(OS.LINUX)
void readOnlyLogFilesWhileCommandsAreAvailable() 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)) {
assertEquals(kibiBytes(128), Files.size(logFiles.getLogFile().getHighestLogFile()));
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());
}
}
use of org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore in project neo4j by neo4j.
the class VersionAwareLogEntryReaderIT method readTillTheEndOfNotPreallocatedFile.
@Test
@DisabledOnOs(OS.LINUX)
void readTillTheEndOfNotPreallocatedFile() 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());
assertEquals(Files.size(logFiles.getLogFile().getHighestLogFile()), logPosition.getByteOffset());
}
}
use of org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore in project neo4j by neo4j.
the class CorruptedLogsTruncatorTest method setUp.
@BeforeEach
void setUp() throws Exception {
databaseDirectory = testDirectory.homePath();
logVersionRepository = new SimpleLogVersionRepository();
SimpleTransactionIdStore transactionIdStore = new SimpleTransactionIdStore();
logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder(databaseDirectory, fs).withRotationThreshold(SINGLE_LOG_FILE_SIZE).withLogVersionRepository(logVersionRepository).withTransactionIdStore(transactionIdStore).withLogEntryReader(logEntryReader()).withStoreId(StoreId.UNKNOWN).withConfig(Config.newBuilder().set(GraphDatabaseInternalSettings.checkpoint_logical_log_rotation_threshold, 1024L).build()).build();
life.add(logFiles);
logPruner = new CorruptedLogsTruncator(databaseDirectory, logFiles, fs, INSTANCE);
}
use of org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore in project neo4j by neo4j.
the class ReversedSingleFileTransactionCursorTest method setUp.
@BeforeEach
void setUp() throws IOException {
LogVersionRepository logVersionRepository = new SimpleLogVersionRepository();
SimpleTransactionIdStore transactionIdStore = new SimpleTransactionIdStore();
logFiles = LogFilesBuilder.builder(databaseLayout, fs).withRotationThreshold(ByteUnit.mebiBytes(10)).withLogVersionRepository(logVersionRepository).withTransactionIdStore(transactionIdStore).withLogEntryReader(logEntryReader()).withStoreId(StoreId.UNKNOWN).build();
life.add(logFiles);
logFile = logFiles.getLogFile();
}
use of org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore in project neo4j by neo4j.
the class TransactionLogAppendAndRotateIT method shouldKeepTransactionsIntactWhenConcurrentlyRotationAndAppending.
@Test
void shouldKeepTransactionsIntactWhenConcurrentlyRotationAndAppending() throws Throwable {
// GIVEN
LogVersionRepository logVersionRepository = new SimpleLogVersionRepository();
LogFiles logFiles = LogFilesBuilder.builder(databaseLayout, fileSystem).withLogVersionRepository(logVersionRepository).withRotationThreshold(ByteUnit.mebiBytes(1)).withTransactionIdStore(new SimpleTransactionIdStore()).withLogEntryReader(logEntryReader()).withStoreId(StoreId.UNKNOWN).build();
life.add(logFiles);
final AtomicBoolean end = new AtomicBoolean();
AllTheMonitoring monitoring = new AllTheMonitoring(end, 100);
TransactionIdStore txIdStore = new SimpleTransactionIdStore();
TransactionMetadataCache metadataCache = new TransactionMetadataCache();
monitoring.setLogFile(logFiles.getLogFile());
Health health = new DatabaseHealth(mock(DatabasePanicEventGenerator.class), NullLog.getInstance());
LogRotation rotation = transactionLogRotation(logFiles, Clock.systemUTC(), health, monitoring);
final TransactionAppender appender = life.add(new BatchingTransactionAppender(logFiles, rotation, metadataCache, txIdStore, health));
// WHEN
Race race = new Race();
for (int i = 0; i < 4; i++) {
race.addContestant(() -> {
while (!end.get()) {
try {
appender.append(new TransactionToApply(sillyTransaction(1_000), CursorContext.NULL), LogAppendEvent.NULL);
} catch (Exception e) {
e.printStackTrace(System.out);
end.set(true);
fail(e.getMessage(), e);
}
}
});
}
race.addContestant(endAfterMax(250, MILLISECONDS, end, monitoring));
race.go();
// THEN
assertTrue(monitoring.numberOfRotations() > 0);
}
Aggregations