[
https://issues.apache.org/jira/browse/TINKERPOP-2240?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
stephen mallette closed TINKERPOP-2240.
---------------------------------------
Resolution: Not A Bug
This isn't a bug. The query you wrote just sent Gremlin into an infinite loop
given the structure of your data. It's no different than if you had:
{code}
gremlin> g = TinkerGraph.open().traversal()
==>graphtraversalsource[tinkergraph[vertices:0 edges:0], standard]
gremlin> g.addV().as('a').addE('self').to('a')
==>e[1][0-self->0]
gremlin> g.V().out()
==>v[0]
gremlin> g.V().out().out()
==>v[0]
gremlin> g.V().repeat(out())
Execution interrupted by ctrl+c
org.apache.tinkerpop.gremlin.process.traversal.util.TraversalInterruptedException
Type ':help' or ':h' for help.
Display stack trace? [yN]
{code}
This is a graph with one vertex that has one edge that points to itself. If you
tell Gremlin to continue going {{out()}} he will continue to traverse that same
cycle indefinitely. The same thing happens in your case, Gremlin traverses to
{{v[6]}} and then traverses {{out()}} it finds {{v[7]}} and then traverses
{{out()}} again only to traverse back to {{v[6]}} and then it repeats that
pattern endlessly. If you have such cycles in your graph structure you need to
account for them in some way. That might mean introducing other ways to break
out of the {{repeat()}} or changing your graph structure to avoid the cycle or
perhaps using {{simplePath()}} to filter such things away as shown here:
{code}
gremlin> g.addV('person').property('name','vadas').as('v').
......1> addV('phone').property('telephone','1234567890').as('p1').
......2> addV('person').property('name','blame').as('b').
......3> addV('phone').property('telephone','09876543321').as('p2').
......4> addE('has').from('v').to('p1').
......5> addE('has').from('b').to('p2').
......6> addE('call').from('p1').to('p2').
......7> addE('call').from('p2').to('p1').iterate()
gremlin>
g.V().has('person','name','vadas').repeat(out().simplePath()).until(has('name','blame')).path()
gremlin>
{code}
Note that it now exits cleanly but returns no results because my graph is not a
complete replication of yours (i.e. there is no path to "blame"), but the point
is that it no longer produces an infinite loop. Note below the inclusion of
{{emit()}} to show the paths it took and the exit of the loop:
{code}
gremlin>
g.V().has('person','name','vadas').repeat(out().simplePath()).emit().until(has('name','blame')).path()
==>[v[0],v[2]]
==>[v[0],v[2],v[6]]
{code}
So, in summary....Gremlin doesn't know your graph structure. Gremlin only does
what your query says to do. It's important to know your data and include
appropriate exits for Gremlin when using a loop step like {{repeat()}}
> In the process of execution, an infinite loop occurs: the gremlin traversal
> is "g.V(1).repeat(out()).until(has('name','blame')).path()",
> -----------------------------------------------------------------------------------------------------------------------------------------
>
> Key: TINKERPOP-2240
> URL: https://issues.apache.org/jira/browse/TINKERPOP-2240
> Project: TinkerPop
> Issue Type: Bug
> Components: process
> Affects Versions: 3.4.2
> Reporter: kaiyangzhang
> Priority: Major
> Attachments: screenshot-1.png
>
>
> *1. The data model is as follows*
> !screenshot-1.png!
> *2. Gremlin traversal is as follows*
> g.V(1)
> .repeat(out())
> .until(has('name','blame'))
> .path()
> *3. In the process of execution, an infinite loop occurs:*
> 1->5 ->6 -> {color:red}7->6->7->6-> 7->6->7.{color}.........
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)