Apache Tinkerpop gremlin-go driver Next() on AddE returns 'E0903: there are no results left'

huangapple go评论86阅读模式
英文:

Apache Tinkerpop gremlin-go driver Next() on AddE returns 'E0903: there are no results left'

问题

在创建新边并返回下一个结果时,gremlin-go可能存在潜在的错误。在为以下问题创建JIRA错误票之前,我只想确保这不是用户错误/我的错误。

使用的Apache Tinkerpop gremlin-go版本与JanusGraph进行连接和交互(0.6.2):github.com/apache/tinkerpop/gremlin-go/v3 v3.6.1。

没有事务的示例:

g := gremlingo.Traversal_().WithRemote(gremlingo.NewDriverRemoteConnection(source))
rv, err := g.AddV("v").Next()
fmt.Println(err)
fmt.Println(rv)
v, err := rv.GetVertex()
fmt.Println(err)
fmt.Println(v)
fmt.Println(v.Id)
re, err := g.AddE("e").Property("some_property", "some-property").From(__.V(v.Id)).To(__.V(v.Id)).Next()
fmt.Println(err)
fmt.Println(re)

返回:

<nil>
result{object=v[%!s(int64=24776)] class=*gremlingo.Vertex}
<nil>
v[%!s(int64=24776)]
24776
E0903: there are no results left
<nil>

带有事务的示例:

g := gremlingo.Traversal_().WithRemote(gremlingo.NewDriverRemoteConnection(source))
tx := g.Tx()
gtx, err := tx.Begin()
if err != nil {
	tx.Close()
}
rv, err = gtx.AddV("v").Next()
if err != nil {
    fmt.Println(err)
	tx.Rollback()
}
fmt.Println(rv)
v, err = rv.GetVertex()
if err != nil {
    fmt.Println(err)
	tx.Rollback()
}
fmt.Println(v)
fmt.Println(v.Id)
re, err = gtx.AddE("e").Property("some_property", "some-property").From(__.V(v.Id)).To(__.V(v.Id)).Next()
if err != nil {
    fmt.Println(err)
	tx.Rollback()
}
fmt.Println(re)
err = txx.Commit()
if err != nil {
	tx.Rollback()
}

返回:

Creating Session based connection
Connecting.
result{object=v[%!s(int64=28872)] class=*gremlingo.Vertex}
v[%!s(int64=28872)]
28872
panic: runtime error: slice bounds out of range [:7623] with capacity 512
goroutine 133 [running]:
github.com/apache/tinkerpop/gremlin-go/v3/driver.readString(0xc00000ec60, 0xc0003b2fa0)
	/go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/graphBinary.go:912 +0x145
github.com/apache/tinkerpop/gremlin-go/v3/driver.readUnqualified(0xc00000ec60, 0xc0003b2fa0, 0x3, 0x0?)
	/go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/graphBinary.go:1308 +0x362
github.com/apache/tinkerpop/gremlin-go/v3/driver.edgeReader(0xc4e860?, 0xc0003b2fa0)
	/go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/graphBinary.go:1079 +0x7d
github.com/apache/tinkerpop/gremlin-go/v3/driver.readFullyQualifiedNullable(0xc00000ec60, 0xc0003b2fa0, 0xe0?)
	/go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/graphBinary.go:1327 +0x3f1
github.com/apache/tinkerpop/gremlin-go/v3/driver.traverserReader(0xc00000ec60, 0xc0003b2fa0)
	/go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/graphBinary.go:1159 +0xdc
github.com/apache/tinkerpop/gremlin-go/v3/driver.readFullyQualifiedNullable(0xc00000ec60, 0xc0003b2fa0, 0x0?)
	/go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/graphBinary.go:1327 +0x3f1
github.com/apache/tinkerpop/gremlin-go/v3/driver.readList(0xc00000ec60, 0xc0003b2fa0)
	/go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/graphBinary.go:953 +0x133
github.com/apache/tinkerpop/gremlin-go/v3/driver.readFullyQualifiedNullable(0xc00000ec60, 0xc0003b2fa0, 0xc0?)
	/go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/graphBinary.go:1327 +0x3f1
github.com/apache/tinkerpop/gremlin-go/v3/driver.graphBinarySerializer.deserializeMessage({0xc00051ec00?}, {0xc0005b2200, 0xc5, 0x200})
	/go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/serializer.go:214 +0x3fa
github.com/apache/tinkerpop/gremlin-go/v3/driver.(*gremlinServerWSProtocol).readLoop(0xc00051ec00, 0x5456ea?, 0x1c?)
	/go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/protocol.go:75 +0x1e2
created by github.com/apache/tinkerpop/gremlin-go/v3/driver.newGremlinServerWSProtocol
	/go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/protocol.go:200 +0x250

当添加.ElementMap()时:

gtx.AddE("e").Property("some_property", "some-property").From(__.V(v.Id)).To(__.V(v.Id)).ElementMap().Next()

返回:

Creating Session based connection
Connecting.
result{object=v[%!s(int64=16576)] class=*gremlingo.Vertex}
v[%!s(int64=16576)]
16576
2023/01/10 11:49:46 Error occurred during operation gremlinServerWSProtocol.readLoop(): 'E0408: unknown data type to deserialize 0x0'
2023/01/10 11:49:46 Read loop error 'E0408: unknown data type to deserialize 0x0', closing read loop.
2023/01/10 11:49:46 Connection error callback invoked, closing protocol.
2023/01/10 11:49:46 Connecting.
E0903: there are no results left
2023/01/10 11:49:47 Closing DriverRemoteConnection with url 'ws://janusgraph:8182/gremlin' with session '3071a486-6649-4f05-8baa-9603163936a3'
2023/01/10 11:49:47 Closing Client with url 'ws://janusgraph:8182/gremlin'
2023/01/10 11:49:47 Closing the connection.

通过gremlin-console的预期结果:

gremlin> g.addE("e").property("some_property", "some-property").from(__.V(24776)).to(__.V(24776)).next()
==>e[8bd-j48-q39-j48][24776-e->24776]
gremlin> g.addE("e").property("some_property", "some-property").from(__.V(24776)).to(__.V(24776)).elementMap().next()
==>id=8pl-j48-q39-j48
==>label=e
==>IN={id=24776, label=v}
==>OUT={id=24776, label=v}
==>some_property=some-property
英文:

Potential bug in gremlin-go when creating new edge and returning next result. Before creating a JIRA bug ticket for the following, I just want to make sure, it is not an user error/ my fault.

Version of Apache Tinkerpop gremlin-go used to connect and interact with JanusGraph (0.6.2): github.com/apache/tinkerpop/gremlin-go/v3 v3.6.1.

Example without transaction:

g := gremlingo.Traversal_().WithRemote(gremlingo.NewDriverRemoteConnection(source))
rv, err := g.AddV(&quot;v&quot;).Next()
fmt.Println(err)
fmt.Println(rv)
v, err := rv.GetVertex()
fmt.Println(err)
fmt.Println(v)
fmt.Println(v.Id)
re, err := g.AddE(&quot;e&quot;).Property(&quot;some_property&quot;, &quot;some-property&quot;).From(__.V(v.Id)).To(__.V(v.Id)).Next()
fmt.Println(err)
fmt.Println(re)

Returns:

&lt;nil&gt;
result{object=v[%!s(int64=24776)] class=*gremlingo.Vertex}
&lt;nil&gt;
v[%!s(int64=24776)]
24776
E0903: there are no results left
&lt;nil&gt;

Example with transaction:

g := gremlingo.Traversal_().WithRemote(gremlingo.NewDriverRemoteConnection(source))
tx := g.Tx()
gtx, err := tx.Begin()
if err != nil {
	tx.Close()
}
rv, err = gtx.AddV(&quot;v&quot;).Next()
if err != nil {
    fmt.Println(err)
	tx.Rollback()
}
fmt.Println(rv)
v, err = rv.GetVertex()
if err != nil {
    fmt.Println(err)
	tx.Rollback()
}
fmt.Println(v)
fmt.Println(v.Id)
re, err = gtx.AddE(&quot;e&quot;).Property(&quot;some_property&quot;, &quot;some-property&quot;).From(__.V(v.Id)).To(__.V(v.Id)).Next()
if err != nil {
    fmt.Println(err)
	tx.Rollback()
}
fmt.Println(re)
err = txx.Commit()
if err != nil {
	tx.Rollback()
}

Returns:

Creating Session based connection
Connecting.
result{object=v[%!s(int64=28872)] class=*gremlingo.Vertex}
v[%!s(int64=28872)]
28872
panic: runtime error: slice bounds out of range [:7623] with capacity 512
goroutine 133 [running]:
github.com/apache/tinkerpop/gremlin-go/v3/driver.readString(0xc00000ec60, 0xc0003b2fa0)
	/go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/graphBinary.go:912 +0x145
github.com/apache/tinkerpop/gremlin-go/v3/driver.readUnqualified(0xc00000ec60, 0xc0003b2fa0, 0x3, 0x0?)
	/go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/graphBinary.go:1308 +0x362
github.com/apache/tinkerpop/gremlin-go/v3/driver.edgeReader(0xc4e860?, 0xc0003b2fa0)
	/go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/graphBinary.go:1079 +0x7d
github.com/apache/tinkerpop/gremlin-go/v3/driver.readFullyQualifiedNullable(0xc00000ec60, 0xc0003b2fa0, 0xe0?)
	/go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/graphBinary.go:1327 +0x3f1
github.com/apache/tinkerpop/gremlin-go/v3/driver.traverserReader(0xc00000ec60, 0xc0003b2fa0)
	/go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/graphBinary.go:1159 +0xdc
github.com/apache/tinkerpop/gremlin-go/v3/driver.readFullyQualifiedNullable(0xc00000ec60, 0xc0003b2fa0, 0x0?)
	/go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/graphBinary.go:1327 +0x3f1
github.com/apache/tinkerpop/gremlin-go/v3/driver.readList(0xc00000ec60, 0xc0003b2fa0)
	/go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/graphBinary.go:953 +0x133
github.com/apache/tinkerpop/gremlin-go/v3/driver.readFullyQualifiedNullable(0xc00000ec60, 0xc0003b2fa0, 0xc0?)
	/go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/graphBinary.go:1327 +0x3f1
github.com/apache/tinkerpop/gremlin-go/v3/driver.graphBinarySerializer.deserializeMessage({0xc00051ec00?}, {0xc0005b2200, 0xc5, 0x200})
	/go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/serializer.go:214 +0x3fa
github.com/apache/tinkerpop/gremlin-go/v3/driver.(*gremlinServerWSProtocol).readLoop(0xc00051ec00, 0x5456ea?, 0x1c?)
	/go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/protocol.go:75 +0x1e2
created by github.com/apache/tinkerpop/gremlin-go/v3/driver.newGremlinServerWSProtocol
	/go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/protocol.go:200 +0x250

When adding .ElementMap():

gtx.AddE(&quot;e&quot;).Property(&quot;some_property&quot;, &quot;some-property&quot;).From(__.V(v.Id)).To(__.V(v.Id)).ElementMap().Next()

Returns:

Creating Session based connection
Connecting.
result{object=v[%!s(int64=16576)] class=*gremlingo.Vertex}
v[%!s(int64=16576)]
16576
2023/01/10 11:49:46 Error occurred during operation gremlinServerWSProtocol.readLoop(): &#39;E0408: unknown data type to deserialize 0x0&#39;
2023/01/10 11:49:46 Read loop error &#39;E0408: unknown data type to deserialize 0x0&#39;, closing read loop.
2023/01/10 11:49:46 Connection error callback invoked, closing protocol.
2023/01/10 11:49:46 Connecting.
E0903: there are no results left
2023/01/10 11:49:47 Closing DriverRemoteConnection with url &#39;ws://janusgraph:8182/gremlin&#39; with session &#39;3071a486-6649-4f05-8baa-9603163936a3&#39;
2023/01/10 11:49:47 Closing Client with url &#39;ws://janusgraph:8182/gremlin&#39;
2023/01/10 11:49:47 Closing the connection.

Expected result via gremlin-console:

gremlin&gt; g.addE(&quot;e&quot;).property(&quot;some_property&quot;, &quot;some-property&quot;).from(__.V(24776)).to(__.V(24776)).next()
==&gt;e[8bd-j48-q39-j48][24776-e-&gt;24776]
gremlin&gt; g.addE(&quot;e&quot;).property(&quot;some_property&quot;, &quot;some-property&quot;).from(__.V(24776)).to(__.V(24776)).elementMap().next()
==&gt;id=8pl-j48-q39-j48
==&gt;label=e
==&gt;IN={id=24776, label=v}
==&gt;OUT={id=24776, label=v}
==&gt;some_property=some-property

答案1

得分: 2

添加一条边会返回该边,而JanusGraph使用一种特殊类型的RelationIdentifier作为边的ID,而Gremlin Go驱动程序不支持该类型。这导致了E0408错误:未知数据类型以反序列化0x0。
如果你只是想在图中创建一条边,一个解决方法是在驱动程序中不返回它,可以使用g.addE().from([...]).to([...]).none()
更多详细信息请参考https://issues.apache.org/jira/browse/TINKERPOP-2828。

英文:

Adding an Edge returns the Edge, and JanusGraph uses a special type RelationIdentifier as the Edge Id, which the Gremlin Go driver does not support. This causes the E0408: unknown data type to deserialize 0x0.
If you just want to create an Edge in the graph, a workaround is to not return it in the driver with g.addE().from([...]).to([...]).none().
More details in https://issues.apache.org/jira/browse/TINKERPOP-2828.

huangapple
  • 本文由 发表于 2023年1月10日 20:01:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/75069668.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定