use of org.neo4j.consistency.report.ConsistencySummaryStatistics in project neo4j by neo4j.
the class FullCheckIntegrationTest method shouldReportWrongRelationshipCountsEntries.
@Test
public void shouldReportWrongRelationshipCountsEntries() throws Exception {
// given
fixture.apply(new GraphStoreFixture.Transaction() {
@Override
protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
tx.incrementRelationshipCount(label1, C, ANY_LABEL, 1);
}
});
// when
ConsistencySummaryStatistics stats = check();
// then
on(stats).verify(RecordType.COUNTS, 1).andThatsAllFolks();
}
use of org.neo4j.consistency.report.ConsistencySummaryStatistics in project neo4j by neo4j.
the class FullCheckIntegrationTest method shouldReportIfThereAreExtraKeys.
@Test
public void shouldReportIfThereAreExtraKeys() throws Exception {
// given
fixture.apply(new GraphStoreFixture.Transaction() {
@Override
protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
tx.incrementNodeCount(1024, /* new label */
1);
}
});
// when
ConsistencySummaryStatistics stats = check();
// then
on(stats).verify(RecordType.COUNTS, 2).andThatsAllFolks();
}
use of org.neo4j.consistency.report.ConsistencySummaryStatistics in project neo4j by neo4j.
the class FullCheckIntegrationTest method shouldReportFirstRelationshipGroupOwnerInconsistency.
@Test
public void shouldReportFirstRelationshipGroupOwnerInconsistency() throws Exception {
// given
fixture.apply(new GraphStoreFixture.Transaction() {
@Override
protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
// node -[first]-> group -[owner]-> otherNode
long node = next.node();
long otherNode = next.node();
long group = next.relationshipGroup();
tx.create(inUse(new NodeRecord(node, true, group, NO_NEXT_PROPERTY.intValue())));
tx.create(inUse(new NodeRecord(otherNode, false, NO_NEXT_RELATIONSHIP.intValue(), NO_NEXT_PROPERTY.intValue())));
tx.create(withOwner(inUse(new RelationshipGroupRecord(group, C)), otherNode));
}
});
// when
ConsistencySummaryStatistics stats = check();
// then
// - next group has other owner that its previous
// - first group has other owner
on(stats).verify(RecordType.NODE, 1).andThatsAllFolks();
}
use of org.neo4j.consistency.report.ConsistencySummaryStatistics in project neo4j by neo4j.
the class FullCheck method execute.
ConsistencySummaryStatistics execute(DirectStoreAccess stores, Log log, Monitor reportMonitor) throws ConsistencyCheckIncompleteException {
ConsistencySummaryStatistics summary = new ConsistencySummaryStatistics();
InconsistencyReport report = new InconsistencyReport(new InconsistencyMessageLogger(log), summary);
OwnerCheck ownerCheck = new OwnerCheck(checkPropertyOwners);
CountsBuilderDecorator countsBuilder = new CountsBuilderDecorator(stores.nativeStores());
CheckDecorator decorator = new CheckDecorator.ChainCheckDecorator(ownerCheck, countsBuilder);
CacheAccess cacheAccess = new DefaultCacheAccess(statistics.getCounts(), threads);
RecordAccess records = recordAccess(stores.nativeStores(), cacheAccess);
execute(stores, decorator, records, report, cacheAccess, reportMonitor);
ownerCheck.scanForOrphanChains(progressFactory);
if (checkGraph) {
CountsAccessor countsAccessor = stores.nativeStores().getCounts();
if (countsAccessor instanceof CountsTracker) {
CountsTracker tracker = (CountsTracker) countsAccessor;
try {
tracker.start();
} catch (Exception e) {
// let's hope it was already started :)
}
}
countsBuilder.checkCounts(countsAccessor, new ConsistencyReporter(records, report), progressFactory);
}
if (!summary.isConsistent()) {
log.warn("Inconsistencies found: " + summary);
}
return summary;
}
use of org.neo4j.consistency.report.ConsistencySummaryStatistics in project neo4j by neo4j.
the class ConsistencyCheckService method runFullConsistencyCheck.
public Result runFullConsistencyCheck(final File storeDir, Config config, ProgressMonitorFactory progressFactory, final LogProvider logProvider, final FileSystemAbstraction fileSystem, final PageCache pageCache, final boolean verbose, File reportDir, CheckConsistencyConfig checkConsistencyConfig) throws ConsistencyCheckIncompleteException {
Log log = logProvider.getLog(getClass());
config = config.with(stringMap(GraphDatabaseSettings.read_only.name(), TRUE, GraphDatabaseSettings.label_index.name(), LabelIndex.AUTO.name()));
StoreFactory factory = new StoreFactory(storeDir, config, new DefaultIdGeneratorFactory(fileSystem), pageCache, fileSystem, logProvider);
ConsistencySummaryStatistics summary;
final File reportFile = chooseReportPath(reportDir);
Log reportLog = new ConsistencyReportLog(Suppliers.lazySingleton(() -> {
try {
return new PrintWriter(createOrOpenAsOuputStream(fileSystem, reportFile, true));
} catch (IOException e) {
throw new RuntimeException(e);
}
}));
// Bootstrap kernel extensions
LifeSupport life = new LifeSupport();
try (NeoStores neoStores = factory.openAllNeoStores()) {
IndexStoreView indexStoreView = new NeoStoreIndexStoreView(LockService.NO_LOCK_SERVICE, neoStores);
Dependencies dependencies = new Dependencies();
dependencies.satisfyDependencies(config, fileSystem, new SimpleLogService(logProvider, logProvider), indexStoreView, pageCache);
KernelContext kernelContext = new SimpleKernelContext(storeDir, UNKNOWN, dependencies);
KernelExtensions extensions = life.add(new KernelExtensions(kernelContext, (Iterable) load(KernelExtensionFactory.class), dependencies, ignore()));
life.start();
LabelScanStore labelScanStore = life.add(extensions.resolveDependency(LabelScanStoreProvider.class, new NamedLabelScanStoreSelectionStrategy(config)).getLabelScanStore());
SchemaIndexProvider indexes = life.add(extensions.resolveDependency(SchemaIndexProvider.class, HighestSelectionStrategy.getInstance()));
int numberOfThreads = defaultConsistencyCheckThreadsNumber();
Statistics statistics;
StoreAccess storeAccess;
AccessStatistics stats = new AccessStatistics();
if (verbose) {
statistics = new VerboseStatistics(stats, new DefaultCounts(numberOfThreads), log);
storeAccess = new AccessStatsKeepingStoreAccess(neoStores, stats);
} else {
statistics = Statistics.NONE;
storeAccess = new StoreAccess(neoStores);
}
storeAccess.initialize();
DirectStoreAccess stores = new DirectStoreAccess(storeAccess, labelScanStore, indexes);
FullCheck check = new FullCheck(progressFactory, statistics, numberOfThreads, checkConsistencyConfig);
summary = check.execute(stores, new DuplicatingLog(log, reportLog));
} finally {
life.shutdown();
}
if (!summary.isConsistent()) {
log.warn("See '%s' for a detailed consistency report.", reportFile.getPath());
return Result.failure(reportFile);
}
return Result.success(reportFile);
}
Aggregations