gnet icon indicating copy to clipboard operation
gnet copied to clipboard

Gnet hangs on receive incomplete request

Open slow-zhang opened this issue 3 years ago • 9 comments

What is your question about gnet? i implement a redis server using gnet, but it can only pass the benchmark when one client send one request (-c 1, -n 1) this is /usr/local/opt/[email protected]/bin/redis-benchmark -t set,get -n 1 -d 100000 -r 100000 -c 1 -p <port>

when set multi request (-c 1, -n 10) this is /usr/local/opt/[email protected]/bin/redis-benchmark -t set,get -n 10 -d 100000 -r 100000 -c 1 -p <port>

here is my impl https://github.com/slow-zhang/gnet-test, am I use gnet by the error way?

slow-zhang avatar Dec 10 '21 07:12 slow-zhang

Use dlv to debug your server and find out why.

panjf2000 avatar Dec 13 '21 11:12 panjf2000

i have using dlv and find the reason just like the title: Gnet hangs on receive incomplete request

slow-zhang avatar Dec 16 '21 05:12 slow-zhang

Share more details with me?

panjf2000 avatar Dec 16 '21 10:12 panjf2000

the redis-bench is hung and for the example the buf is always nil.

you can try the cmd by you self: /usr/local/opt/[email protected]/bin/redis-benchmark -t set,get -n 10 -d 100000 -r 100000 -c 1 -p <port> image

slow-zhang avatar Dec 17 '21 09:12 slow-zhang

@slow-zhang @panjf2000 if len(buf) == 0 is true, we should return nil,gerrors.ErrIncompletePacketinstead of just return.

Please see this example of using client in gnet: https://github.com/Spongecaptain/gnet-examples/blob/master/examples/custom_codec/protocol/pb.go#L95, it may help.

wathenjiang avatar Dec 18 '21 14:12 wathenjiang

thanks for helping! i will fix it later

slow-zhang avatar Dec 28 '21 06:12 slow-zhang

after I fixed this error , the code can not even pass the benchmark when one client send one request (-c 1, -n 1)

here is the code after fixed: https://github.com/slow-zhang/gnet-test/blob/main/main.go#L142

image

slow-zhang avatar Dec 28 '21 06:12 slow-zhang

Please upgrade to gnet v1.6.4 and try again.

panjf2000 avatar Dec 30 '21 05:12 panjf2000

so can i assume that there is a bug fix for it?

slow-zhang avatar Jan 06 '22 06:01 slow-zhang