JanusGraph / janusgraph

JanusGraph: an open-source, distributed graph database
https://janusgraph.org
Other
5.26k stars 1.16k forks source link

Getting java.lang.NullPointerException on ElasticSearch indexed field #1300

Open graphdb2 opened 5 years ago

graphdb2 commented 5 years ago

Hello,

I am getting this exception when query edges

:> g.E().hasLabel('state').has('CisCode','FUTISKY').has('from',lte(1539885480000)).has('_hash','f55eae38855173399afdfc99')
[gremlin-server-exec-3] WARN  org.apache.tinkerpop.gremlin.server.op.AbstractEvalOpProcessor  - Exception processing a script on request [RequestMessage{, requestId=5bbcf977-54d1-416e-bcac-674ca18830be, op='eval', processor='', args={gremlin=g.E().hasLabel('state').has('CisCode','FUTISKY').has('from',lte(1539885480000)).has('_hash','f55eae38855173399afdfc99'), bindings={}, batchSize=64}}].
java.lang.NullPointerException
        at org.janusgraph.graphdb.util.ElementHelper.getValues(ElementHelper.java:41)
        at org.janusgraph.graphdb.query.condition.PredicateCondition.evaluate(PredicateCondition.java:66)
        at org.janusgraph.graphdb.query.condition.And.evaluate(And.java:55)
        at org.janusgraph.graphdb.query.graph.GraphCentricQuery.matches(GraphCentricQuery.java:152)
        at org.janusgraph.graphdb.query.QueryProcessor.lambda$getFilterIterator$2(QueryProcessor.java:133)
        at com.google.common.collect.Iterators$7.computeNext(Iterators.java:652)
        at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:143)
        at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:138)
        at org.janusgraph.graphdb.query.ResultSetIterator.nextInternal(ResultSetIterator.java:54)
        at org.janusgraph.graphdb.query.ResultSetIterator.<init>(ResultSetIterator.java:44)
        at org.janusgraph.graphdb.query.QueryProcessor.iterator(QueryProcessor.java:66)
        at com.google.common.collect.Iterables$7.iterator(Iterables.java:613)
        at org.janusgraph.graphdb.tinkerpop.optimize.JanusGraphStep.executeGraphCentryQuery(JanusGraphStep.java:156)
        at org.janusgraph.graphdb.tinkerpop.optimize.JanusGraphStep.lambda$null$1(JanusGraphStep.java:95)
        at java.lang.Iterable.forEach(Unknown Source)
        at org.janusgraph.graphdb.tinkerpop.optimize.JanusGraphStep.lambda$new$2(JanusGraphStep.java:95)
        at org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep.processNextStart(GraphStep.java:142)
        at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:143)
        at org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.hasNext(DefaultTraversal.java:192)
        at org.apache.tinkerpop.gremlin.server.op.AbstractOpProcessor.handleIterator(AbstractOpProcessor.java:89)
        at org.apache.tinkerpop.gremlin.server.op.AbstractEvalOpProcessor.lambda$evalOpInternal$5(AbstractEvalOpProcessor.java:252)
        at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.lambda$eval$0(GremlinExecutor.java:274)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

Janusgraph: version 0.3.0

pluradj commented 5 years ago

what is the mixed index definition?

graphdb2 commented 5 years ago
import org.janusgraph.graphdb.database.management.ManagementSystem

graph.getOpenTransactions()
graph.tx().rollback() //Never create new indexes while a transaction is active
mgmt = graph.openManagement()
ciscode = mgmt.getPropertyKey('CisCode')
from = mgmt.getPropertyKey('from')
hash = mgmt.getPropertyKey('_hash')

state = mgmt.getEdgeLabel('state')
indexName = 'byCisCodeFromHashES5'

mgmt.buildIndex(indexName , Edge.class).addKey(ciscode).addKey(from).addKey(hash).indexOnly(state).buildMixedIndex("janus")
mgmt.commit()
//Wait for the index to become available
mgmt.awaitGraphIndexStatus(graph, indexName).call()
//Reindex the existing data
mgmt = graph.openManagement()
mgmt.updateIndex(mgmt.getGraphIndex(indexName), SchemaAction.REINDEX).get()
mgmt.commit()

mgmt = graph.openManagement()
mgmt.updateIndex(mgmt.getGraphIndex(indexName), SchemaAction.ENABLE_INDEX)
mgmt.commit()

mgmt = graph.openManagement()
report = mgmt.awaitGraphIndexStatus(graph, indexName).status(SchemaStatus.ENABLED).call()
mgmt.rollback()
pluradj commented 5 years ago

what are the property key definitions?

pluradj commented 5 years ago

I'll mention that it would be much easier if you would provide a reproducible example including the schema, indexes, and some example data.

pluradj commented 5 years ago

The stack trace goes through the JanusGraph code, so it seems that there's a bug scenario here. We just need to isolate a reproducible test case.

graphdb2 commented 5 years ago

I reproduced this with a stale ES index, so if I start from an empty graph but with a populated ES index I get this exception.

pluradj commented 5 years ago

Thanks, using a stale ES index is a critical piece of information. In this scenario, did you run reindexing to try to clear it up?

Sounds like there needs to be some enhancement around validating if an existing index matches with the graph storage.