internal PropertyAndNodeIndexedCheck(IndexAccessors indexes, PropertyReader propertyReader, CacheAccess cacheAccess)
 {
     this._indexes        = indexes;
     this._propertyReader = propertyReader;
     this._cacheAccess    = cacheAccess;
 }
Example #2
0
 internal RelationshipToIndexCheck(IList <StoreIndexDescriptor> relationshipIndexes, IndexAccessors indexes, PropertyReader propertyReader)
 {
     this._relationshipIndexes = relationshipIndexes.ToArray();
     this._indexes             = indexes;
     this._propertyReader      = propertyReader;
 }
Example #3
0
        public virtual IList <ConsistencyCheckerTask> CreateTasksForFullCheck(bool checkLabelScanStore, bool checkIndexes, bool checkGraph)
        {
            IList <ConsistencyCheckerTask> tasks = new List <ConsistencyCheckerTask>();

            if (checkGraph)
            {
                MandatoryProperties mandatoryProperties = new MandatoryProperties(_nativeStores);
                StoreProcessor      processor           = _multiPass.processor(CheckStage.Stage1NSPropsLabels, PROPERTIES);
                tasks.Add(Create(CheckStage.Stage1NSPropsLabels.name(), _nativeStores.NodeStore, processor, ROUND_ROBIN));
                //RelationshipStore pass - check label counts using cached labels, check properties, skip nodes and relationships
                processor = _multiPass.processor(CheckStage.Stage2RSLabels, LABELS);
                _multiPass.reDecorateRelationship(processor, RelationshipRecordCheck.relationshipRecordCheckForwardPass());
                tasks.Add(Create(CheckStage.Stage2RSLabels.name(), _nativeStores.RelationshipStore, processor, ROUND_ROBIN));
                //NodeStore pass - just cache nextRel and inUse
                tasks.Add(new CacheTask.CacheNextRel(CheckStage.Stage3NSNextRel, _cacheAccess, Scanner.scan(_nativeStores.NodeStore)));
                //RelationshipStore pass - check nodes inUse, FirstInFirst, FirstInSecond using cached info
                processor = _multiPass.processor(CheckStage.Stage4RSNextRel, NODES);
                _multiPass.reDecorateRelationship(processor, RelationshipRecordCheck.relationshipRecordCheckBackwardPass(new PropertyChain <>(mandatoryProperties.ForRelationships(_reporter))));
                tasks.Add(Create(CheckStage.Stage4RSNextRel.name(), _nativeStores.RelationshipStore, processor, ROUND_ROBIN));
                //NodeStore pass - just cache nextRel and inUse
                _multiPass.reDecorateNode(processor, NodeRecordCheck.toCheckNextRel(), true);
                _multiPass.reDecorateNode(processor, NodeRecordCheck.toCheckNextRelationshipGroup(), false);
                tasks.Add(new CacheTask.CheckNextRel(CheckStage.Stage5CheckNextRel, _cacheAccess, _nativeStores, processor));
                // source chain
                //RelationshipStore pass - forward scan of source chain using the cache.
                processor = _multiPass.processor(CheckStage.Stage6RSForward, RELATIONSHIPS);
                _multiPass.reDecorateRelationship(processor, RelationshipRecordCheck.relationshipRecordCheckSourceChain());
                tasks.Add(Create(CheckStage.Stage6RSForward.name(), _nativeStores.RelationshipStore, processor, QueueDistribution.RELATIONSHIPS));
                //RelationshipStore pass - reverse scan of source chain using the cache.
                processor = _multiPass.processor(CheckStage.Stage7RSBackward, RELATIONSHIPS);
                _multiPass.reDecorateRelationship(processor, RelationshipRecordCheck.relationshipRecordCheckSourceChain());
                tasks.Add(Create(CheckStage.Stage7RSBackward.name(), _nativeStores.RelationshipStore, processor, QueueDistribution.RELATIONSHIPS));

                //relationshipGroup
                StoreProcessor relGrpProcessor = _multiPass.processor(Stage_Fields.ParallelForward, RELATIONSHIP_GROUPS);
                tasks.Add(Create("RelationshipGroupStore-RelGrp", _nativeStores.RelationshipGroupStore, relGrpProcessor, ROUND_ROBIN));

                PropertyReader propertyReader = new PropertyReader(_nativeStores);
                tasks.Add(RecordScanner(CheckStage.Stage8PSProps.name(), new IterableStore <>(_nativeStores.NodeStore, true), new PropertyAndNode2LabelIndexProcessor(_reporter, checkIndexes ? _indexes : null, propertyReader, _cacheAccess, mandatoryProperties.ForNodes(_reporter)), CheckStage.Stage8PSProps, ROUND_ROBIN, new IterableStore <>(_nativeStores.PropertyStore, true)));

                // Checking that relationships are in their expected relationship indexes.
                IList <StoreIndexDescriptor> relationshipIndexes = Iterables.stream(_indexes.onlineRules()).filter(rule => rule.schema().entityType() == EntityType.RELATIONSHIP).collect(Collectors.toList());
                if (checkIndexes && relationshipIndexes.Count > 0)
                {
                    tasks.Add(RecordScanner(CheckStage.Stage9RSIndexes.name(), new IterableStore <>(_nativeStores.RelationshipStore, true), new RelationshipIndexProcessor(_reporter, _indexes, propertyReader, relationshipIndexes), CheckStage.Stage9RSIndexes, ROUND_ROBIN, new IterableStore <>(_nativeStores.PropertyStore, true)));
                }

                tasks.Add(Create("StringStore-Str", _nativeStores.StringStore, _multiPass.processor(Stage_Fields.SequentialForward, STRINGS), ROUND_ROBIN));
                tasks.Add(Create("ArrayStore-Arrays", _nativeStores.ArrayStore, _multiPass.processor(Stage_Fields.SequentialForward, ARRAYS), ROUND_ROBIN));
            }
            // The schema store is verified in multiple passes that share state since it fits into memory
            // and we care about the consistency of back references (cf. SemanticCheck)
            // PASS 1: Dynamic record chains
            tasks.Add(Create("SchemaStore", _nativeStores.SchemaStore, ROUND_ROBIN));
            // PASS 2: Rule integrity and obligation build up
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.consistency.checking.SchemaRecordCheck schemaCheck = new org.neo4j.consistency.checking.SchemaRecordCheck(new org.neo4j.kernel.impl.store.SchemaStorage(nativeStores.getSchemaStore()), indexes);
            SchemaRecordCheck schemaCheck = new SchemaRecordCheck(new SchemaStorage(_nativeStores.SchemaStore), _indexes);

            tasks.Add(new SchemaStoreProcessorTask <>("SchemaStoreProcessor-check_rules", _statistics, _numberOfThreads, _nativeStores.SchemaStore, _nativeStores, "check_rules", schemaCheck, _multiPartBuilder, _cacheAccess, _defaultProcessor, ROUND_ROBIN));
            // PASS 3: Obligation verification and semantic rule uniqueness
            tasks.Add(new SchemaStoreProcessorTask <>("SchemaStoreProcessor-check_obligations", _statistics, _numberOfThreads, _nativeStores.SchemaStore, _nativeStores, "check_obligations", schemaCheck.ForObligationChecking(), _multiPartBuilder, _cacheAccess, _defaultProcessor, ROUND_ROBIN));
            if (checkGraph)
            {
                tasks.Add(Create("RelationshipTypeTokenStore", _nativeStores.RelationshipTypeTokenStore, ROUND_ROBIN));
                tasks.Add(Create("PropertyKeyTokenStore", _nativeStores.PropertyKeyTokenStore, ROUND_ROBIN));
                tasks.Add(Create("LabelTokenStore", _nativeStores.LabelTokenStore, ROUND_ROBIN));
                tasks.Add(Create("RelationshipTypeNameStore", _nativeStores.RelationshipTypeNameStore, ROUND_ROBIN));
                tasks.Add(Create("PropertyKeyNameStore", _nativeStores.PropertyKeyNameStore, ROUND_ROBIN));
                tasks.Add(Create("LabelNameStore", _nativeStores.LabelNameStore, ROUND_ROBIN));
                tasks.Add(Create("NodeDynamicLabelStore", _nativeStores.NodeDynamicLabelStore, ROUND_ROBIN));
            }

            ConsistencyReporter filteredReporter = _multiPass.reporter(NODES);

            if (checkLabelScanStore)
            {
                long highId = _nativeStores.NodeStore.HighId;
                tasks.Add(new LabelIndexDirtyCheckTask(this));
                tasks.Add(RecordScanner("LabelScanStore", new GapFreeAllEntriesLabelScanReader(_labelScanStore.allNodeLabelRanges(), highId), new LabelScanDocumentProcessor(filteredReporter, new LabelScanCheck()), Stage_Fields.SequentialForward, ROUND_ROBIN));
            }
            if (checkIndexes)
            {
                tasks.Add(new IndexDirtyCheckTask(this));
                TokenNameLookup tokenNameLookup = new NonTransactionalTokenNameLookup(_tokenHolders, true);
                foreach (StoreIndexDescriptor indexRule in _indexes.onlineRules())
                {
                    tasks.Add(RecordScanner(format("Index_%d", indexRule.Id), new IndexIterator(_indexes.accessorFor(indexRule)), new IndexEntryProcessor(filteredReporter, new IndexCheck(indexRule), indexRule, tokenNameLookup), Stage_Fields.SequentialForward, ROUND_ROBIN));
                }
            }
            return(tasks);
        }