Created
February 3, 2015 16:32
-
-
Save luanne/4640bd00b602d8f47506 to your computer and use it in GitHub Desktop.
When a node is created by the batch inserter with a set of labels (of which one has a unique constraint defined on it), and then the labels are replaced with another set of labels in a particular order, the consistency checker produces "This node was not found in the expected index". Post this, the node cannot be retrieved by label MobileUser an…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.graphaware; | |
| import com.rancard.domain.Labels; | |
| import org.neo4j.graphdb.DynamicLabel; | |
| import org.neo4j.graphdb.Label; | |
| import org.neo4j.graphdb.schema.ConstraintCreator; | |
| import org.neo4j.unsafe.batchinsert.BatchInserter; | |
| import org.neo4j.unsafe.batchinsert.BatchInserters; | |
| import java.util.*; | |
| import static org.neo4j.helpers.collection.MapUtil.map; | |
| /** | |
| * Created by luanne on 03/02/15. | |
| */ | |
| public class NodeNotFoundInExpectedIndexWithConstraint { | |
| public static void main(String[] args) { | |
| String path = "/tmp/test" + new Date().getTime() + ".graph.db"; | |
| System.out.println("path = " + path); | |
| BatchInserter inserter = BatchInserters.inserter(path, Collections.EMPTY_MAP); | |
| long nodeId = inserter.createNode(map("msisdn", 254755802176l), DynamicLabel.label("MobileUser"), DynamicLabel.label("SocialUser"), DynamicLabel.label("Essar"), DynamicLabel.label("Kenya")); | |
| //Looks like it is dependent somehow on the order of the labels | |
| inserter.setNodeLabels(nodeId,DynamicLabel.label("Essar"),DynamicLabel.label("MobileUser"),DynamicLabel.label("Kenya"),DynamicLabel.label("RendezvousUser"),DynamicLabel.label("Vendor")); | |
| ConstraintCreator constraintCreator = inserter.createDeferredConstraint(DynamicLabel.label("MobileUser")); | |
| constraintCreator.assertPropertyIsUnique("msisdn").create(); | |
| inserter.shutdown(); | |
| } | |
| /* | |
| Consistency checker produces | |
| 2015-02-03 16:30:41.845+0000 INFO [org.neo4j]: ERROR: This node was not found in the expected index. | |
| Node[0,used=true,rel=-1,prop=0,labels=Inline(0x505080c002:[2, 0, 3, 4, 5]),light] | |
| Inconsistent with: IndexRule[id=1, label=0, kind=CONSTRAINT_INDEX_RULE, provider={key=lucene, version=1.0}, properties=0, owner=2] 254755802176 | |
| ........... 100% | |
| 2015-02-03 16:30:41.909+0000 INFO [org.neo4j]: Inconsistencies found: ConsistencySummaryStatistics{ | |
| Number of errors: 1 | |
| Number of warnings: 0 | |
| Number of inconsistent NODE records: 1 | |
| */ | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment