Search in sources :

Example 6 with SimpleLogVersionRepository

use of org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository 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.");
}
Also used : LogFile(org.neo4j.kernel.impl.transaction.log.files.LogFile) SimpleTransactionIdStore(org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore) LogFiles(org.neo4j.kernel.impl.transaction.log.files.LogFiles) SimpleLogVersionRepository(org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository) LogEntryWriter(org.neo4j.kernel.impl.transaction.log.entry.LogEntryWriter) Lifespan(org.neo4j.kernel.lifecycle.Lifespan) CommandFailedException(org.neo4j.cli.CommandFailedException) Test(org.junit.jupiter.api.Test)

Example 7 with SimpleLogVersionRepository

use of org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository 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));
        }
    }
}
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) Test(org.junit.jupiter.api.Test)

Example 8 with SimpleLogVersionRepository

use of org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository 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 9 with SimpleLogVersionRepository

use of org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository 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 10 with SimpleLogVersionRepository

use of org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository 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)

Aggregations

SimpleLogVersionRepository (org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository)17 SimpleTransactionIdStore (org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore)17 Test (org.junit.jupiter.api.Test)13 LogFiles (org.neo4j.kernel.impl.transaction.log.files.LogFiles)8 Lifespan (org.neo4j.kernel.lifecycle.Lifespan)5 LogPosition (org.neo4j.kernel.impl.transaction.log.LogPosition)4 BeforeEach (org.junit.jupiter.api.BeforeEach)3 LogFile (org.neo4j.kernel.impl.transaction.log.files.LogFile)3 LogVersionRepository (org.neo4j.storageengine.api.LogVersionRepository)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 Config (org.neo4j.configuration.Config)2 TestCommandReaderFactory (org.neo4j.kernel.impl.api.TestCommandReaderFactory)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 CountDownLatch (java.util.concurrent.CountDownLatch)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 DisabledOnOs (org.junit.jupiter.api.condition.DisabledOnOs)1 EnabledOnOs (org.junit.jupiter.api.condition.EnabledOnOs)1