[ 
https://issues.apache.org/jira/browse/TINKERPOP-3076?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17889882#comment-17889882
 ] 

Cole Greer commented on TINKERPOP-3076:
---------------------------------------

I've looked into this, and the truncation is happening because the request 
message is larger than the default  `WriteBufferSize` config (1MB). Gorilla 
implicitly limits the size of a single frame to size of the write buffer, and 
any data exceeding that limit is sent in a subsequent frame.

Gremlin-server is not equipped to handle request messages split between 
multiple frames, and thus fails to parse the message in this case.

The above example can be fixed simply by increasing the write buffer size to 
something large enough to hold the entire request (and of course ensuring that 
the server is configured with a sufficiently large maxContentLength):

{code:go}
driverRemoteConnection, err := 
gremlingo.NewDriverRemoteConnection("ws://localhost:8182/gremlin",
        func(settings *gremlingo.DriverRemoteConnectionSettings) {
                settings.WriteBufferSize = 2000000
        })
{code}

I think we can simply add a client-side check in gremlin-go return a 
descriptive error message if a user attempts to send a request which exceeds 
the write buffer size. This would function similarly to how `maxContentLength` 
is implemented in the java driver.

> Incorrect handling of large requests in Go GLV
> ----------------------------------------------
>
>                 Key: TINKERPOP-3076
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-3076
>             Project: TinkerPop
>          Issue Type: Bug
>          Components: go
>    Affects Versions: 3.6.7, 3.7.2
>            Reporter: Valentyn Kahamlyk
>            Priority: Blocker
>
> When trying to send a request longer than about a megabyte, go GLV does not 
> work correctly, possibly truncates data.
> Simple reproducer 
> {code:go}
> func main() {
>     driverRemoteConnection, err := 
> gremlingo.NewDriverRemoteConnection("ws://localhost:8182/gremlin")
>     if err != nil {
>        fmt.Println(err)
>        return
>     }
>     defer driverRemoteConnection.Close()
>     g := gremlingo.Traversal_().WithRemote(driverRemoteConnection)
>     const count = 1100
>     var ids [count]string
>     const idLength = 1000
>     result := make([]byte, idLength)
>     for i := 0; i < idLength; i++ {
>        result[i] = 65
>     }
>     id := string(result)
>     for i := 0; i < count; i++ {
>        ids[i] = id
>     }
>     r, err := g.V(ids).Count().ToList()
>     if err != nil {
>        fmt.Println("err: ", err)
>        return
>     }
>     fmt.Println("found: ", r[0].GetString()) 
> }{code}
> with `count = 1000` it works as expected.
> Python GLV works as expected with same request.
> Error logged in Gremlin Server 
> {code:java}
> io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: 
> readerIndex(1048338) + length(1000) exceeds writerIndex(1048543): 
> PooledUnsafeDirectByteBuf(ridx: 1048338, widx: 1048543, cap: 1048576){code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to