NullPointerException when sending multiple queries at the same time


Fernando Medina <fer...@...>
 

Hi

I'm new on graph databases and back-end programming in general.
I have a query to create a vertex, If I send the query multiple times simultaneously to get multi-threading performance I get NullPointerException when reading the created vertices in another query later.
If I send the same query one at a time without multi threading everything works perfectly.
I was told JanusGraph is thread safe for reading and writing that is why I'm using it.
This is my query:


g.withSideEffect('nothing', [])
.inject(objectsReadyForDB)
.unfold()
.map(
__.as('data')
.select('userId')
.as('dap')
.select('data')
.choose(
__.V()
.hasLabel(verticesLabel)
.has('userId', __.where(P.eq('dap'))),
__.select('nothing'),
__.addV("user"),
),
)
.unfold();

It seems the choose() part is causing the issue, If I remove that it also works.

This is the full stack trace:

  name: 'ResponseError',
  statusCode: 500,
  statusMessage: null,
  statusAttributes: Map {
    'stackTrace' => 'java.lang.NullPointerException\n' +
      '\tat org.janusgraph.graphdb.types.vertices.PropertyKeyVertex.cardinality(PropertyKeyVertex.java:36)\n' +
      '\tat org.janusgraph.graphdb.transaction.StandardJanusGraphTx.addProperty(StandardJanusGraphTx.java:745)\n' +
      '\tat org.janusgraph.graphdb.vertices.AbstractVertex.property(AbstractVertex.java:152)\n' +
      '\tat org.janusgraph.core.JanusGraphVertex.property(JanusGraphVertex.java:72)\n' +
      '\tat org.janusgraph.graphdb.util.ElementHelper.attachProperties(ElementHelper.java:80)\n' +
      '\tat org.janusgraph.graphdb.tinkerpop.JanusGraphBlueprintsTransaction.addVertex(JanusGraphBlueprintsTransaction.java:122)\n' +
      '\tat org.janusgraph.graphdb.tinkerpop.JanusGraphBlueprintsGraph.addVertex(JanusGraphBlueprintsGraph.java:141)\n' +
      '\tat org.janusgraph.graphdb.tinkerpop.JanusGraphBlueprintsGraph.addVertex(JanusGraphBlueprintsGraph.java:59)\n' +
      '\tat org.apache.tinkerpop.gremlin.process.traversal.step.map.AddVertexStep.map(AddVertexStep.java:81)\n' +
      '\tat org.apache.tinkerpop.gremlin.process.traversal.step.map.AddVertexStep.map(AddVertexStep.java:43)\n' +
      '\tat org.apache.tinkerpop.gremlin.process.traversal.step.map.MapStep.processNextStart(MapStep.java:37)\n' +
      '\tat org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:143)\n' +
      '\tat org.apache.tinkerpop.gremlin.process.traversal.step.branch.BranchStep.standardAlgorithm(BranchStep.java:126)\n' +
      '\tat org.apache.tinkerpop.gremlin.process.traversal.step.util.ComputerAwareStep.processNextStart(ComputerAwareStep.java:46)\n' +
      '\tat org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:143)\n' +
      '\tat org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.hasNext(DefaultTraversal.java:197)\n' +
      '\tat org.apache.tinkerpop.gremlin.process.traversal.step.map.TraversalMapStep.map(TraversalMapStep.java:48)\n' +
      '\tat org.apache.tinkerpop.gremlin.process.traversal.step.map.MapStep.processNextStart(MapStep.java:37)\n' +
      '\tat org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:143)\n' +
      '\tat org.apache.tinkerpop.gremlin.process.traversal.step.util.ExpandableStepIterator.next(ExpandableStepIterator.java:50)\n' +
      '\tat org.apache.tinkerpop.gremlin.process.traversal.step.map.FlatMapStep.processNextStart(FlatMapStep.java:48)\n' +
      '\tat org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:143)\n' +
      '\tat org.apache.tinkerpop.gremlin.process.traversal.step.util.ExpandableStepIterator.next(ExpandableStepIterator.java:50)\n' +
      '\tat org.apache.tinkerpop.gremlin.process.traversal.step.filter.FilterStep.processNextStart(FilterStep.java:37)\n' +
      '\tat org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:143)\n' +
      '\tat org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.hasNext(DefaultTraversal.java:197)\n' +
      '\tat org.apache.tinkerpop.gremlin.server.util.TraverserIterator.fillBulker(TraverserIterator.java:69)\n' +
      '\tat org.apache.tinkerpop.gremlin.server.util.TraverserIterator.hasNext(TraverserIterator.java:56)\n' +
      '\tat org.apache.tinkerpop.gremlin.server.op.traversal.TraversalOpProcessor.handleIterator(TraversalOpProcessor.java:512)\n' +
      '\tat org.apache.tinkerpop.gremlin.server.op.traversal.TraversalOpProcessor.lambda$iterateBytecodeTraversal$4(TraversalOpProcessor.java:411)\n' +
      '\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\n' +
      '\tat java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)\n' +
      '\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\n' +
      '\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\n' +
      '\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\n' +
      '\tat java.lang.Thread.run(Thread.java:748)\n',
    'exceptions' => [ 'java.lang.NullPointerException' ]

Join janusgraph-users@lists.lfaidata.foundation to automatically receive all group messages.