Incremental schema changes - Property Key constraint does not exist

Hi All, in our use-case the graph schema is changing over time and we have issues to incrementally add properties to the schema as we get error in the below scenario: 1. day 1: we create a graph with an initial schema: person node with firstName property. 2. day 2: we try adding lastName property to the person node. This still works and one can create persons with lastName 3. day 3: we try adding fullName property to the person node. This does not work any more as gp_traversal.addV('person').property('fullName', 'test full name') throws error: Property Key constraint does not exist for given Vertex Label [person] and property key [fullName]. We use JanusGraph 1.0.0 with Cassandra 4.0.11 backend. Below are some snippets to reproduce the above. Could you please have a look and tell us what we are doing wrong? Day 1 - create initial schema in Gremlin console with session mode - see day1.groovy enclosed Day 2 - adding lastName property to the person node in Gremlin console with session mode - sew day2.groovy At this point, once we connect to the graph database, gp_traversal.addV('person').property('lastName', 'test last name') works fine. Day 3 - adding fullName property to the person node in Gremlin console with session mode - see day3.groovy At this point, once we connect to the graph database, gp_traversal.addV('person').property('fullName', 'test full name') throws Property Key constraint does not exist for given Vertex Label [person] and property key [fullName]. We have checked with printSchema() and all properties are created as expected, so gp_traversal.addV().property('fullName', 'test full name') works fine. Once we tried mgmt.getVertexLabel('person').mappedProperties() we could not see fullName property listed. We have noticed that if we stop and restart JanusGraph, the fullName property starts working as expected but we are looking for a way to modify the schema without restarting the server. Thank you.
Solution:
Hello, you need to close graph in order to take into account new schema constraint, no need to restart server. You can close graph with ConfiguredGraphFactory.close, then it will automatically open again with GremlinExecutorGraphBinder in JanusGraphManager....
Jump to solution
2 Replies
Solution
paull8147
paull81473mo ago
Hello, you need to close graph in order to take into account new schema constraint, no need to restart server. You can close graph with ConfiguredGraphFactory.close, then it will automatically open again with GremlinExecutorGraphBinder in JanusGraphManager.
pm_osc
pm_osc3mo ago
Thanks a lot for your help on this. Indeed, closing the graph helped with the constraints.
Want results from more Discord servers?
Add your server