Search in sources :

Example 1 with DatabaseHealth

use of org.neo4j.kernel.internal.DatabaseHealth in project neo4j by neo4j.

the class NeoStoreDataSourceTest method shouldAlwaysShutdownLifeEvenWhenCheckPointingFails.

@Test
public void shouldAlwaysShutdownLifeEvenWhenCheckPointingFails() throws Exception {
    // Given
    File storeDir = dir.graphDbDir();
    FileSystemAbstraction fs = this.fs.get();
    PageCache pageCache = pageCacheRule.getPageCache(fs);
    DatabaseHealth databaseHealth = mock(DatabaseHealth.class);
    when(databaseHealth.isHealthy()).thenReturn(true);
    IOException ex = new IOException("boom!");
    doThrow(ex).when(databaseHealth).assertHealthy(// <- this is a trick to simulate a failure during checkpointing
    IOException.class);
    NeoStoreDataSource dataSource = dsRule.getDataSource(storeDir, fs, pageCache, emptyMap(), databaseHealth);
    dataSource.start();
    try {
        // When
        dataSource.stop();
        fail("it should have thrown");
    } catch (LifecycleException e) {
        // Then
        assertEquals(ex, e.getCause());
    }
}
Also used : DatabaseHealth(org.neo4j.kernel.internal.DatabaseHealth) LifecycleException(org.neo4j.kernel.lifecycle.LifecycleException) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) IOException(java.io.IOException) File(java.io.File) PageCache(org.neo4j.io.pagecache.PageCache) Test(org.junit.Test)

Example 2 with DatabaseHealth

use of org.neo4j.kernel.internal.DatabaseHealth in project neo4j by neo4j.

the class RecordStorageEngineTest method panicOnExceptionDuringCommandsApply.

@Test
public void panicOnExceptionDuringCommandsApply() throws Exception {
    IllegalStateException failure = new IllegalStateException("Too many open files");
    RecordStorageEngine engine = storageEngineRule.getWith(fsRule.get(), pageCacheRule.getPageCache(fsRule.get())).databaseHealth(databaseHealth).transactionApplierTransformer(facade -> transactionApplierFacadeTransformer(facade, failure)).build();
    CommandsToApply commandsToApply = mock(CommandsToApply.class);
    try {
        engine.apply(commandsToApply, TransactionApplicationMode.INTERNAL);
        fail("Exception expected");
    } catch (Exception exception) {
        assertSame(failure, Exceptions.rootCause(exception));
    }
    verify(databaseHealth).panic(any(Throwable.class));
}
Also used : RecordFormat(org.neo4j.kernel.impl.store.format.RecordFormat) TransactionIdStore(org.neo4j.kernel.impl.transaction.log.TransactionIdStore) StoreFileMetadata(org.neo4j.storageengine.api.StoreFileMetadata) EphemeralFileSystemRule(org.neo4j.test.rule.fs.EphemeralFileSystemRule) Exceptions(org.neo4j.helpers.Exceptions) BatchTransactionApplierFacade(org.neo4j.kernel.impl.api.BatchTransactionApplierFacade) IOLimiter(org.neo4j.io.pagecache.IOLimiter) AtomicReference(java.util.concurrent.atomic.AtomicReference) TransactionToApply(org.neo4j.kernel.impl.api.TransactionToApply) DelegatingPageCache(org.neo4j.io.pagecache.DelegatingPageCache) RecordStorageEngineRule(org.neo4j.test.rule.RecordStorageEngineRule) Assert.assertSame(org.junit.Assert.assertSame) Assert.assertThat(org.junit.Assert.assertThat) Mockito.doThrow(org.mockito.Mockito.doThrow) PageCacheRule(org.neo4j.test.rule.PageCacheRule) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) TransactionApplicationMode(org.neo4j.storageengine.api.TransactionApplicationMode) CountsTracker(org.neo4j.kernel.impl.store.counts.CountsTracker) Assert.fail(org.junit.Assert.fail) StoreFile(org.neo4j.kernel.impl.storemigration.StoreFile) PageCache(org.neo4j.io.pagecache.PageCache) UnderlyingStorageException(org.neo4j.kernel.impl.store.UnderlyingStorageException) BatchTransactionApplier(org.neo4j.kernel.impl.api.BatchTransactionApplier) TransactionRepresentation(org.neo4j.kernel.impl.transaction.TransactionRepresentation) Assert.assertNotNull(org.junit.Assert.assertNotNull) Collection(java.util.Collection) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IOException(java.io.IOException) Mockito.when(org.mockito.Mockito.when) File(java.io.File) Mockito.verify(org.mockito.Mockito.verify) RuleChain(org.junit.rules.RuleChain) Matchers.any(org.mockito.Matchers.any) Rule(org.junit.Rule) CountsAccessor(org.neo4j.kernel.impl.api.CountsAccessor) StoreFileType(org.neo4j.kernel.impl.storemigration.StoreFileType) DatabaseHealth(org.neo4j.kernel.internal.DatabaseHealth) Matchers.sameInstance(org.hamcrest.Matchers.sameInstance) StoreType(org.neo4j.kernel.impl.store.StoreType) Matchers.equalTo(org.hamcrest.Matchers.equalTo) CommandsToApply(org.neo4j.storageengine.api.CommandsToApply) Optional(java.util.Optional) FakeCommitment(org.neo4j.kernel.impl.transaction.log.FakeCommitment) Matchers.anyOf(org.hamcrest.Matchers.anyOf) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) Mockito.mock(org.mockito.Mockito.mock) CommandsToApply(org.neo4j.storageengine.api.CommandsToApply) UnderlyingStorageException(org.neo4j.kernel.impl.store.UnderlyingStorageException) IOException(java.io.IOException) Test(org.junit.Test)

Example 3 with DatabaseHealth

use of org.neo4j.kernel.internal.DatabaseHealth in project neo4j by neo4j.

the class NeoStoreDataSource method buildTransactionLogs.

private NeoStoreTransactionLogModule buildTransactionLogs(File storeDir, Config config, LogProvider logProvider, JobScheduler scheduler, FileSystemAbstraction fileSystemAbstraction, StorageEngine storageEngine, LogEntryReader<ReadableClosablePositionAwareChannel> logEntryReader, SynchronizedArrayIdOrderingQueue legacyIndexTransactionOrdering, TransactionIdStore transactionIdStore, LogVersionRepository logVersionRepository) {
    TransactionMetadataCache transactionMetadataCache = new TransactionMetadataCache(100_000);
    LogHeaderCache logHeaderCache = new LogHeaderCache(1000);
    final PhysicalLogFiles logFiles = new PhysicalLogFiles(storeDir, PhysicalLogFile.DEFAULT_NAME, fileSystemAbstraction);
    final PhysicalLogFile logFile = life.add(new PhysicalLogFile(fileSystemAbstraction, logFiles, config.get(GraphDatabaseSettings.logical_log_rotation_threshold), transactionIdStore::getLastCommittedTransactionId, logVersionRepository, physicalLogMonitor, logHeaderCache));
    final PhysicalLogFileInformation.LogVersionToTimestamp logInformation = version -> {
        LogPosition position = LogPosition.start(version);
        try (ReadableLogChannel channel = logFile.getReader(position)) {
            LogEntry entry;
            while ((entry = logEntryReader.readLogEntry(channel)) != null) {
                if (entry instanceof LogEntryStart) {
                    return entry.<LogEntryStart>as().getTimeWritten();
                }
            }
        }
        return -1;
    };
    final LogFileInformation logFileInformation = new PhysicalLogFileInformation(logFiles, logHeaderCache, transactionIdStore::getLastCommittedTransactionId, logInformation);
    if (config.get(GraphDatabaseFacadeFactory.Configuration.ephemeral)) {
        config = config.withDefaults(stringMap(GraphDatabaseSettings.keep_logical_logs.name(), "1 files"));
    }
    String pruningConf = config.get(GraphDatabaseSettings.keep_logical_logs);
    LogPruneStrategy logPruneStrategy = fromConfigValue(fs, logFileInformation, logFiles, pruningConf);
    final LogPruning logPruning = new LogPruningImpl(logPruneStrategy, logProvider);
    final LogRotation logRotation = new LogRotationImpl(monitors.newMonitor(LogRotation.Monitor.class), logFile, databaseHealth);
    final TransactionAppender appender = life.add(new BatchingTransactionAppender(logFile, logRotation, transactionMetadataCache, transactionIdStore, legacyIndexTransactionOrdering, databaseHealth));
    final LogicalTransactionStore logicalTransactionStore = new PhysicalLogicalTransactionStore(logFile, transactionMetadataCache, logEntryReader);
    int txThreshold = config.get(GraphDatabaseSettings.check_point_interval_tx);
    final CountCommittedTransactionThreshold countCommittedTransactionThreshold = new CountCommittedTransactionThreshold(txThreshold);
    long timeMillisThreshold = config.get(GraphDatabaseSettings.check_point_interval_time);
    TimeCheckPointThreshold timeCheckPointThreshold = new TimeCheckPointThreshold(timeMillisThreshold, clock);
    CheckPointThreshold threshold = CheckPointThresholds.or(countCommittedTransactionThreshold, timeCheckPointThreshold);
    final CheckPointerImpl checkPointer = new CheckPointerImpl(transactionIdStore, threshold, storageEngine, logPruning, appender, databaseHealth, logProvider, tracers.checkPointTracer, ioLimiter, storeCopyCheckPointMutex);
    long recurringPeriod = Math.min(timeMillisThreshold, TimeUnit.SECONDS.toMillis(10));
    CheckPointScheduler checkPointScheduler = new CheckPointScheduler(checkPointer, scheduler, recurringPeriod, databaseHealth);
    life.add(checkPointer);
    life.add(checkPointScheduler);
    return new NeoStoreTransactionLogModule(logicalTransactionStore, logFileInformation, logFiles, logFile, logRotation, checkPointer, appender, legacyIndexTransactionOrdering);
}
Also used : LegacyIndexStore(org.neo4j.kernel.impl.index.LegacyIndexStore) StoreId(org.neo4j.kernel.impl.store.StoreId) ResourceIterator(org.neo4j.graphdb.ResourceIterator) Lifecycles(org.neo4j.kernel.lifecycle.Lifecycles) RelationshipTypeTokenHolder(org.neo4j.kernel.impl.core.RelationshipTypeTokenHolder) SystemNanoClock(org.neo4j.time.SystemNanoClock) AccessCapability(org.neo4j.kernel.impl.factory.AccessCapability) SchemaWriteGuard(org.neo4j.kernel.impl.api.SchemaWriteGuard) CheckPointThresholds(org.neo4j.kernel.impl.transaction.log.checkpoint.CheckPointThresholds) VersionAwareLogEntryReader(org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader) RecordStorageEngine(org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine) LogHeader(org.neo4j.kernel.impl.transaction.log.entry.LogHeader) SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) Map(java.util.Map) IndexProviders(org.neo4j.kernel.spi.legacyindex.IndexProviders) TokenNameLookup(org.neo4j.kernel.api.TokenNameLookup) KernelSchemaStateStore(org.neo4j.kernel.impl.api.KernelSchemaStateStore) RecordFormatPropertyConfigurator(org.neo4j.kernel.impl.store.format.RecordFormatPropertyConfigurator) TransactionMonitor(org.neo4j.kernel.impl.transaction.TransactionMonitor) DefaultRecoverySPI(org.neo4j.kernel.recovery.DefaultRecoverySPI) HighestSelectionStrategy(org.neo4j.kernel.extension.dependency.HighestSelectionStrategy) TransactionEventHandlers(org.neo4j.kernel.internal.TransactionEventHandlers) IdReuseEligibility(org.neo4j.kernel.impl.store.id.IdReuseEligibility) LogEntryStart(org.neo4j.kernel.impl.transaction.log.entry.LogEntryStart) StartupStatisticsProvider(org.neo4j.kernel.impl.core.StartupStatisticsProvider) StateHandlingStatementOperations(org.neo4j.kernel.impl.api.StateHandlingStatementOperations) PropertyAccessor(org.neo4j.kernel.api.index.PropertyAccessor) PositionToRecoverFrom(org.neo4j.kernel.recovery.PositionToRecoverFrom) SimpleTriggerInfo(org.neo4j.kernel.impl.transaction.log.checkpoint.SimpleTriggerInfo) LockSupport(java.util.concurrent.locks.LockSupport) SchemaStateConcern(org.neo4j.kernel.impl.api.SchemaStateConcern) UpdateableSchemaState(org.neo4j.kernel.impl.api.UpdateableSchemaState) Kernel(org.neo4j.kernel.impl.api.Kernel) TransactionCommitProcess(org.neo4j.kernel.impl.api.TransactionCommitProcess) Logger(org.neo4j.logging.Logger) LabelScanStoreProvider(org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider) LogEntry(org.neo4j.kernel.impl.transaction.log.entry.LogEntry) GraphDatabaseSettings(org.neo4j.graphdb.factory.GraphDatabaseSettings) Tracers(org.neo4j.kernel.monitoring.tracing.Tracers) SynchronizedArrayIdOrderingQueue(org.neo4j.kernel.impl.util.SynchronizedArrayIdOrderingQueue) Guard(org.neo4j.kernel.guard.Guard) IndexingService(org.neo4j.kernel.impl.api.index.IndexingService) IndexImplementation(org.neo4j.kernel.spi.legacyindex.IndexImplementation) Exceptions(org.neo4j.helpers.Exceptions) ConstraintSemantics(org.neo4j.kernel.impl.constraints.ConstraintSemantics) RecordFormatSelector(org.neo4j.kernel.impl.store.format.RecordFormatSelector) TimeCheckPointThreshold(org.neo4j.kernel.impl.transaction.log.checkpoint.TimeCheckPointThreshold) LabelScanStore(org.neo4j.kernel.api.labelscan.LabelScanStore) JobScheduler(org.neo4j.kernel.impl.util.JobScheduler) Supplier(java.util.function.Supplier) ReadableClosablePositionAwareChannel(org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel) LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition) PropertyKeyTokenHolder(org.neo4j.kernel.impl.core.PropertyKeyTokenHolder) CountCommittedTransactionThreshold(org.neo4j.kernel.impl.transaction.log.checkpoint.CountCommittedTransactionThreshold) GuardingStatementOperations(org.neo4j.kernel.impl.api.GuardingStatementOperations) DeleteStoresFromOtherLabelScanStoreProviders(org.neo4j.kernel.extension.dependency.DeleteStoresFromOtherLabelScanStoreProviders) Lifecycle(org.neo4j.kernel.lifecycle.Lifecycle) LogEntryReader(org.neo4j.kernel.impl.transaction.log.entry.LogEntryReader) TransactionMetadataCache(org.neo4j.kernel.impl.transaction.log.TransactionMetadataCache) IOException(java.io.IOException) LatestCheckPointFinder(org.neo4j.kernel.recovery.LatestCheckPointFinder) File(java.io.File) StackingQueryRegistrationOperations(org.neo4j.kernel.impl.api.StackingQueryRegistrationOperations) CheckPointScheduler(org.neo4j.kernel.impl.transaction.log.checkpoint.CheckPointScheduler) LockingStatementOperations(org.neo4j.kernel.impl.api.LockingStatementOperations) Procedures(org.neo4j.kernel.impl.proc.Procedures) IndexConfigStore(org.neo4j.kernel.impl.index.IndexConfigStore) KernelTransactionsSnapshot(org.neo4j.kernel.impl.api.KernelTransactionsSnapshot) LogPruneStrategyFactory.fromConfigValue(org.neo4j.kernel.impl.transaction.log.pruning.LogPruneStrategyFactory.fromConfigValue) StoreCopyCheckPointMutex(org.neo4j.kernel.impl.transaction.log.checkpoint.StoreCopyCheckPointMutex) ReentrantLockService(org.neo4j.kernel.impl.locking.ReentrantLockService) DatabaseMigrator(org.neo4j.kernel.impl.storemigration.DatabaseMigrator) LifecycleAdapter(org.neo4j.kernel.lifecycle.LifecycleAdapter) LogPruneStrategy(org.neo4j.kernel.impl.transaction.log.pruning.LogPruneStrategy) Log(org.neo4j.logging.Log) StoreFileMetadata(org.neo4j.storageengine.api.StoreFileMetadata) IdGeneratorFactory(org.neo4j.kernel.impl.store.id.IdGeneratorFactory) GraphDatabaseFacadeFactory(org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory) CheckPointThreshold(org.neo4j.kernel.impl.transaction.log.checkpoint.CheckPointThreshold) IdTypeConfigurationProvider(org.neo4j.kernel.impl.store.id.configuration.IdTypeConfigurationProvider) BatchingTransactionAppender(org.neo4j.kernel.impl.transaction.log.BatchingTransactionAppender) Dependencies(org.neo4j.kernel.impl.util.Dependencies) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) KernelAPI(org.neo4j.kernel.api.KernelAPI) PhysicalLogFileInformation(org.neo4j.kernel.impl.transaction.log.PhysicalLogFileInformation) DiagnosticsExtractor(org.neo4j.kernel.info.DiagnosticsExtractor) ConstraintEnforcingEntityOperations(org.neo4j.kernel.impl.api.ConstraintEnforcingEntityOperations) NeoStoreFileListing(org.neo4j.kernel.impl.transaction.state.NeoStoreFileListing) LogRotation(org.neo4j.kernel.impl.transaction.log.rotation.LogRotation) StatementOperationContainer(org.neo4j.kernel.impl.api.StatementOperationContainer) DataIntegrityValidatingStatementOperations(org.neo4j.kernel.impl.api.DataIntegrityValidatingStatementOperations) QueryRegistrationOperations(org.neo4j.kernel.impl.api.operations.QueryRegistrationOperations) CheckPointerImpl(org.neo4j.kernel.impl.transaction.log.checkpoint.CheckPointerImpl) ReadableLogChannel(org.neo4j.kernel.impl.transaction.log.ReadableLogChannel) StatementLocksFactory(org.neo4j.kernel.impl.locking.StatementLocksFactory) PageCache(org.neo4j.io.pagecache.PageCache) Recovery(org.neo4j.kernel.recovery.Recovery) StorageEngine(org.neo4j.storageengine.api.StorageEngine) LogVersionRepository(org.neo4j.kernel.impl.transaction.log.LogVersionRepository) LogService(org.neo4j.kernel.impl.logging.LogService) KernelException(org.neo4j.kernel.api.exceptions.KernelException) PhysicalLogFile(org.neo4j.kernel.impl.transaction.log.PhysicalLogFile) StoreReadLayer(org.neo4j.storageengine.api.StoreReadLayer) LoggingLogFileMonitor(org.neo4j.kernel.impl.transaction.log.LoggingLogFileMonitor) NamedLabelScanStoreSelectionStrategy(org.neo4j.kernel.extension.dependency.NamedLabelScanStoreSelectionStrategy) MetaDataStore(org.neo4j.kernel.impl.store.MetaDataStore) StatementOperationParts(org.neo4j.kernel.impl.api.StatementOperationParts) LegacyIndexProviderLookup(org.neo4j.kernel.impl.api.LegacyIndexProviderLookup) DependencyResolver(org.neo4j.graphdb.DependencyResolver) LogHeaderCache(org.neo4j.kernel.impl.transaction.log.LogHeaderCache) KernelTransactions(org.neo4j.kernel.impl.api.KernelTransactions) TransactionHeaderInformationFactory(org.neo4j.kernel.impl.transaction.TransactionHeaderInformationFactory) PhysicalLogicalTransactionStore(org.neo4j.kernel.impl.transaction.log.PhysicalLogicalTransactionStore) TransactionAppender(org.neo4j.kernel.impl.transaction.log.TransactionAppender) TransactionIdStore(org.neo4j.kernel.impl.transaction.log.TransactionIdStore) LogicalTransactionStore(org.neo4j.kernel.impl.transaction.log.LogicalTransactionStore) Monitors(org.neo4j.kernel.monitoring.Monitors) LogProvider(org.neo4j.logging.LogProvider) HashMap(java.util.HashMap) DiagnosticsManager(org.neo4j.kernel.info.DiagnosticsManager) IOLimiter(org.neo4j.io.pagecache.IOLimiter) RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) ConstraintIndexCreator(org.neo4j.kernel.impl.api.state.ConstraintIndexCreator) StoreMigrator(org.neo4j.kernel.impl.storemigration.participant.StoreMigrator) LogFileInformation(org.neo4j.kernel.impl.transaction.log.LogFileInformation) LogRotationImpl(org.neo4j.kernel.impl.transaction.log.rotation.LogRotationImpl) DiagnosticsPhase(org.neo4j.kernel.info.DiagnosticsPhase) LogPruningImpl(org.neo4j.kernel.impl.transaction.log.pruning.LogPruningImpl) LogPruning(org.neo4j.kernel.impl.transaction.log.pruning.LogPruning) MapUtil.stringMap(org.neo4j.helpers.collection.MapUtil.stringMap) PhysicalLogFiles(org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles) AutoIndexing(org.neo4j.kernel.api.legacyindex.AutoIndexing) Config(org.neo4j.kernel.configuration.Config) LockService(org.neo4j.kernel.impl.locking.LockService) Setting(org.neo4j.graphdb.config.Setting) LabelTokenHolder(org.neo4j.kernel.impl.core.LabelTokenHolder) VisibleMigrationProgressMonitor(org.neo4j.kernel.impl.storemigration.monitoring.VisibleMigrationProgressMonitor) TimeUnit(java.util.concurrent.TimeUnit) DatabaseHealth(org.neo4j.kernel.internal.DatabaseHealth) CommitProcessFactory(org.neo4j.kernel.impl.api.CommitProcessFactory) Clock(java.time.Clock) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) TransactionHooks(org.neo4j.kernel.impl.api.TransactionHooks) LogPruneStrategy(org.neo4j.kernel.impl.transaction.log.pruning.LogPruneStrategy) CheckPointerImpl(org.neo4j.kernel.impl.transaction.log.checkpoint.CheckPointerImpl) TimeCheckPointThreshold(org.neo4j.kernel.impl.transaction.log.checkpoint.TimeCheckPointThreshold) BatchingTransactionAppender(org.neo4j.kernel.impl.transaction.log.BatchingTransactionAppender) PhysicalLogicalTransactionStore(org.neo4j.kernel.impl.transaction.log.PhysicalLogicalTransactionStore) LogicalTransactionStore(org.neo4j.kernel.impl.transaction.log.LogicalTransactionStore) PhysicalLogFiles(org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles) LogPruning(org.neo4j.kernel.impl.transaction.log.pruning.LogPruning) TransactionMonitor(org.neo4j.kernel.impl.transaction.TransactionMonitor) LoggingLogFileMonitor(org.neo4j.kernel.impl.transaction.log.LoggingLogFileMonitor) VisibleMigrationProgressMonitor(org.neo4j.kernel.impl.storemigration.monitoring.VisibleMigrationProgressMonitor) TimeCheckPointThreshold(org.neo4j.kernel.impl.transaction.log.checkpoint.TimeCheckPointThreshold) CheckPointThreshold(org.neo4j.kernel.impl.transaction.log.checkpoint.CheckPointThreshold) LogEntry(org.neo4j.kernel.impl.transaction.log.entry.LogEntry) LogRotationImpl(org.neo4j.kernel.impl.transaction.log.rotation.LogRotationImpl) LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition) LogEntryStart(org.neo4j.kernel.impl.transaction.log.entry.LogEntryStart) PhysicalLogicalTransactionStore(org.neo4j.kernel.impl.transaction.log.PhysicalLogicalTransactionStore) ReadableLogChannel(org.neo4j.kernel.impl.transaction.log.ReadableLogChannel) CountCommittedTransactionThreshold(org.neo4j.kernel.impl.transaction.log.checkpoint.CountCommittedTransactionThreshold) LogPruningImpl(org.neo4j.kernel.impl.transaction.log.pruning.LogPruningImpl) BatchingTransactionAppender(org.neo4j.kernel.impl.transaction.log.BatchingTransactionAppender) TransactionAppender(org.neo4j.kernel.impl.transaction.log.TransactionAppender) TransactionMetadataCache(org.neo4j.kernel.impl.transaction.log.TransactionMetadataCache) CheckPointScheduler(org.neo4j.kernel.impl.transaction.log.checkpoint.CheckPointScheduler) PhysicalLogFileInformation(org.neo4j.kernel.impl.transaction.log.PhysicalLogFileInformation) LogFileInformation(org.neo4j.kernel.impl.transaction.log.LogFileInformation) LogRotation(org.neo4j.kernel.impl.transaction.log.rotation.LogRotation) LogHeaderCache(org.neo4j.kernel.impl.transaction.log.LogHeaderCache) PhysicalLogFile(org.neo4j.kernel.impl.transaction.log.PhysicalLogFile) PhysicalLogFileInformation(org.neo4j.kernel.impl.transaction.log.PhysicalLogFileInformation)

Example 4 with DatabaseHealth

use of org.neo4j.kernel.internal.DatabaseHealth in project neo4j by neo4j.

the class Runner method createBatchingTransactionAppender.

private BatchingTransactionAppender createBatchingTransactionAppender(TransactionIdStore transactionIdStore, TransactionMetadataCache transactionMetadataCache, LogFile logFile) {
    Log log = NullLog.getInstance();
    KernelEventHandlers kernelEventHandlers = new KernelEventHandlers(log);
    DatabasePanicEventGenerator panicEventGenerator = new DatabasePanicEventGenerator(kernelEventHandlers);
    DatabaseHealth databaseHealth = new DatabaseHealth(panicEventGenerator, log);
    LogRotationImpl logRotation = new LogRotationImpl(NOOP_LOGROTATION_MONITOR, logFile, databaseHealth);
    return new BatchingTransactionAppender(logFile, logRotation, transactionMetadataCache, transactionIdStore, IdOrderingQueue.BYPASS, databaseHealth);
}
Also used : DatabaseHealth(org.neo4j.kernel.internal.DatabaseHealth) KernelEventHandlers(org.neo4j.kernel.internal.KernelEventHandlers) Log(org.neo4j.logging.Log) NullLog(org.neo4j.logging.NullLog) BatchingTransactionAppender(org.neo4j.kernel.impl.transaction.log.BatchingTransactionAppender) DatabasePanicEventGenerator(org.neo4j.kernel.impl.core.DatabasePanicEventGenerator) LogRotationImpl(org.neo4j.kernel.impl.transaction.log.rotation.LogRotationImpl)

Example 5 with DatabaseHealth

use of org.neo4j.kernel.internal.DatabaseHealth in project neo4j by neo4j.

the class NeoStoreDataSourceTest method databaseHealthShouldBeHealedOnStart.

@Test
public void databaseHealthShouldBeHealedOnStart() throws Throwable {
    NeoStoreDataSource theDataSource = null;
    try {
        DatabaseHealth databaseHealth = new DatabaseHealth(mock(DatabasePanicEventGenerator.class), NullLogProvider.getInstance().getLog(DatabaseHealth.class));
        theDataSource = dsRule.getDataSource(dir.graphDbDir(), fs.get(), pageCacheRule.getPageCache(fs.get()), stringMap(), databaseHealth);
        databaseHealth.panic(new Throwable());
        theDataSource.start();
        databaseHealth.assertHealthy(Throwable.class);
    } finally {
        if (theDataSource != null) {
            theDataSource.stop();
            theDataSource.shutdown();
        }
    }
}
Also used : DatabaseHealth(org.neo4j.kernel.internal.DatabaseHealth) DatabasePanicEventGenerator(org.neo4j.kernel.impl.core.DatabasePanicEventGenerator) Test(org.junit.Test)

Aggregations

DatabaseHealth (org.neo4j.kernel.internal.DatabaseHealth)7 Test (org.junit.Test)5 PageCache (org.neo4j.io.pagecache.PageCache)5 File (java.io.File)3 IOException (java.io.IOException)3 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)3 Exceptions (org.neo4j.helpers.Exceptions)2 IOLimiter (org.neo4j.io.pagecache.IOLimiter)2 BatchingTransactionAppender (org.neo4j.kernel.impl.transaction.log.BatchingTransactionAppender)2 TransactionIdStore (org.neo4j.kernel.impl.transaction.log.TransactionIdStore)2 LogRotationImpl (org.neo4j.kernel.impl.transaction.log.rotation.LogRotationImpl)2 Log (org.neo4j.logging.Log)2 StoreFileMetadata (org.neo4j.storageengine.api.StoreFileMetadata)2 Clock (java.time.Clock)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Optional (java.util.Optional)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 TimeUnit (java.util.concurrent.TimeUnit)1