Search in sources :

Example 11 with SimpleTransactionIdStore

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());
    }
}
Also used : SimpleTransactionIdStore(org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore) LogFiles(org.neo4j.kernel.impl.transaction.log.files.LogFiles) SimpleLogVersionRepository(org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository) Lifespan(org.neo4j.kernel.lifecycle.Lifespan) LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition) EnabledOnOs(org.junit.jupiter.api.condition.EnabledOnOs) Test(org.junit.jupiter.api.Test)

Example 12 with SimpleTransactionIdStore

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());
    }
}
Also used : SimpleTransactionIdStore(org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore) LogFiles(org.neo4j.kernel.impl.transaction.log.files.LogFiles) SimpleLogVersionRepository(org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository) Lifespan(org.neo4j.kernel.lifecycle.Lifespan) LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) Test(org.junit.jupiter.api.Test)

Example 13 with SimpleTransactionIdStore

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);
}
Also used : SimpleTransactionIdStore(org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore) SimpleLogVersionRepository(org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 14 with SimpleTransactionIdStore

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();
}
Also used : SimpleTransactionIdStore(org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore) SimpleLogVersionRepository(org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository) LogVersionRepository(org.neo4j.storageengine.api.LogVersionRepository) SimpleLogVersionRepository(org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 15 with SimpleTransactionIdStore

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);
}
Also used : DatabaseHealth(org.neo4j.monitoring.DatabaseHealth) TransactionToApply(org.neo4j.kernel.impl.api.TransactionToApply) TransactionIdStore(org.neo4j.storageengine.api.TransactionIdStore) SimpleTransactionIdStore(org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore) SimpleTransactionIdStore(org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore) Health(org.neo4j.monitoring.Health) DatabaseHealth(org.neo4j.monitoring.DatabaseHealth) LogFiles(org.neo4j.kernel.impl.transaction.log.files.LogFiles) SimpleLogVersionRepository(org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository) DatabasePanicEventGenerator(org.neo4j.kernel.monitoring.DatabasePanicEventGenerator) LogVersionRepository(org.neo4j.storageengine.api.LogVersionRepository) SimpleLogVersionRepository(org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository) IOException(java.io.IOException) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Race(org.neo4j.test.Race) LogRotation(org.neo4j.kernel.impl.transaction.log.rotation.LogRotation) FileLogRotation.transactionLogRotation(org.neo4j.kernel.impl.transaction.log.rotation.FileLogRotation.transactionLogRotation) Test(org.junit.jupiter.api.Test)

Aggregations

SimpleTransactionIdStore (org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore)23 Test (org.junit.jupiter.api.Test)17 SimpleLogVersionRepository (org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository)17 LogFiles (org.neo4j.kernel.impl.transaction.log.files.LogFiles)14 Lifespan (org.neo4j.kernel.lifecycle.Lifespan)7 TransactionIdStore (org.neo4j.storageengine.api.TransactionIdStore)6 LogFile (org.neo4j.kernel.impl.transaction.log.files.LogFile)5 LogPosition (org.neo4j.kernel.impl.transaction.log.LogPosition)4 LifeSupport (org.neo4j.kernel.lifecycle.LifeSupport)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 LogVersionRepository (org.neo4j.storageengine.api.LogVersionRepository)3 ArrayList (java.util.ArrayList)2 Config (org.neo4j.configuration.Config)2 TestCommandReaderFactory (org.neo4j.kernel.impl.api.TestCommandReaderFactory)2 TransactionLogWriter (org.neo4j.kernel.impl.transaction.log.TransactionLogWriter)2 VersionAwareLogEntryReader (org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader)2 DatabaseHealth (org.neo4j.monitoring.DatabaseHealth)2 IOException (java.io.IOException)1 Path (java.nio.file.Path)1