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("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)
Returns:
<nil>
result{object=v[%!s(int64=24776)] class=*gremlingo.Vertex}
<nil>
v[%!s(int64=24776)]
24776
E0903: there are no results left
<nil>
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("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()
}
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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/driver/protocol.go:200 0x250
When adding .ElementMap()
:
gtx.AddE("e").Property("some_property", "some-property").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(): '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.
Expected result via 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
CodePudding user response:
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.