Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StackOverflowError adding alot of vertex properties inside one traverser #3479

Closed
mrckzgl opened this issue Jan 20, 2023 · 2 comments
Closed

Comments

@mrckzgl
Copy link

mrckzgl commented Jan 20, 2023

  • Version: 0.6.1
  • Storage Backend: berkleyje
  • Mixed Index Backend: lucene
  • Expected Behavior: No Stackoverflow Error
  • Current Behavior: Stackoverflow Error

Running this gremlin query inside JRuby:

traversal = dbtx.traversal.add_v()

large_list.each{|v|
  traverser.property(VertexProperty::Cardinality::list, 'search_value', v["value"])
}

traverser.iterate()

results in:

2023-01-20 16:15:48 - Java::JavaLang::StackOverflowError - :
	org.apache.tinkerpop.gremlin.process.traversal.step.util.ExpandableStepIterator.next(org/apache/tinkerpop/gremlin/process/traversal/step/util/ExpandableStepIterator.java:55)
	org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SideEffectStep.processNextStart(org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SideEffectStep.java:38)
	org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(org/apache/tinkerpop/gremlin/process/traversal/step/util/AbstractStep.java:150)
	org.apache.tinkerpop.gremlin.process.traversal.step.util.ExpandableStepIterator.next(org/apache/tinkerpop/gremlin/process/traversal/step/util/ExpandableStepIterator.java:55)
	org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SideEffectStep.processNextStart(org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SideEffectStep.java:38)
	org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(org/apache/tinkerpop/gremlin/process/traversal/step/util/AbstractStep.java:150)
	org.apache.tinkerpop.gremlin.process.traversal.step.util.ExpandableStepIterator.next(org/apache/tinkerpop/gremlin/process/traversal/step/util/ExpandableStepIterator.java:55)
	org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SideEffectStep.processNextStart(org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SideEffectStep.java:38)
	org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(org/apache/tinkerpop/gremlin/process/traversal/step/util/AbstractStep.java:150)
	org.apache.tinkerpop.gremlin.process.traversal.step.util.ExpandableStepIterator.next(org/apache/tinkerpop/gremlin/process/traversal/step/util/ExpandableStepIterator.java:55)
	org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SideEffectStep.processNextStart(org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SideEffectStep.java:38)
	org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(org/apache/tinkerpop/gremlin/process/traversal/step/util/AbstractStep.java:150)
	org.apache.tinkerpop.gremlin.process.traversal.step.util.ExpandableStepIterator.next(org/apache/tinkerpop/gremlin/process/traversal/step/util/ExpandableStepIterator.java:55)
	org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SideEffectStep.processNextStart(org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SideEffectStep.java:38)
	org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(org/apache/tinkerpop/gremlin/process/traversal/step/util/AbstractStep.java:150)

For a list of size ~4000.

Not sure if this is a gremlin issue or a JanusGraph issue. Anyway the apache tinkerpop github repo does not have an issue tracker, so I would be very grateful if this is a gremlin issue to get advise where to post the issue.

best

EDIT: Sorry wrong point in source code

@mrckzgl mrckzgl changed the title StackOverflowError running gremlin query with side effect StackOverflowError adding alot of vertex properties inside one traverser Jan 20, 2023
@mrckzgl
Copy link
Author

mrckzgl commented Jan 23, 2023

ok, as I opened the issue I was not aware that we are actually doing ~4000 traverser.property calls. Refactoring that to pass a large list to one property call instead of one value to a lot of property calls:

traverser.property(VertexProperty::Cardinality::list, 'search_value', large_list.map{|p|p["value"]})

does not generate the stack overflow luckily. Still, I would be very interested to hear opinions if the OP is considered a bug or a legitimate limitation (which IMHO should still be documented in the gremlin reference)?

@mrckzgl
Copy link
Author

mrckzgl commented Jan 24, 2023

ok I just found out in the tinkerpop reference, that it is not possible to provide an array / list of values in a .property step, which is very weird honestly and unexpected, as properties with cardinality list explicitly exists. What actually happens when providing a list (but only if the property key already exists) is that for this list .toString() is called and the string representation of that list is added as value. This implementation will lead to very hard to debug problems. Instead of casting to string an error should be thrown IMHO if an unsupported value type is provided by .property.

Anyhow, this also means that above workaround is not possible and the current implementation definitively is a bug IMHO.

Another workaround might be to split the addition of propery values into multiple traversers, sth like this:

node = dbtx.traversal.add_v().next

traverser = dbtx.traversal.v(node)
first_list_of_x_values.each{|v|
  traverser.property(VertexProperty::Cardinality::list, 'search_value', v["value"])
}
traverser.iterate()

traverser = dbtx.traversal.v(node)
second_list_of_x_values.each{|v|
  traverser.property(VertexProperty::Cardinality::list, 'search_value', v["value"])
}
traverser.iterate()

...

Haven't tested if it works, anyhow it is quite unconvenient, and also impossible to know the exact value of x ...

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

1 participant