go-graphite/graphite-clickhouse

Carbonapi got unexpected EOF on some queries responce

msaf1980 opened this issue · 2 comments

Carbonapi got unexpected EOF when trying to unmarshal go-graphite response on some query. Without any error from graphite-clickhouse. Points returned and as I see in debugger - no points a lost.

Carbonapi debbugger session

> github.com/go-graphite/protocol/carbonapi_v2_pb.(*FetchResponse).Unmarshal() ./vendor/github.com/go-graphite/protocol/carbonapi_v2_pb/carbonapi_v2_pb.pb.go:2258 (hits goroutine(52):1 total:1) (PC: 0x94e35b)
  2253:				}
  2254:				if skippy < 0 {
  2255:					return ErrInvalidLengthCarbonapiV2Pb
  2256:				}
  2257:				if (iNdEx + skippy) > l {
=>2258:					return io.ErrUnexpectedEOF
  2259:				}
  2260:				iNdEx += skippy
  2261:			}
  2262:		}
  2263:	
(dlv) p skippy
1056241
(dlv) p iNdEx
549
(dlv) p l
611

Last commit without error:

commit 37b91dfd4c65e06cd2de03f44c1b0556289787df (HEAD -> master)
Author: Vladimir Smirnov <civiloid@google.com>
Date:   Tue Aug 18 18:25:47 2020 +0200

    Add support for carbonapi_v3_pb requests with different from and until
    
    This fixes request handling when query used timeShift

Next commit produce a panic

commit f3583294580b6a83b66b95330ece3093fe3acf7a (HEAD -> master)
Author: Mikhail f. Shiryaev <mr.felixoid@gmail.com>
Date:   Mon Aug 24 01:12:11 2020 +0200

    Moderate data fetching refactoring
2021/04/09 17:35:50 http: panic serving 127.0.0.1:39720: runtime error: integer divide by zero
goroutine 81 [running]:
net/http.(*conn).serve.func1(0xc00098e000)
	/usr/local/go/src/net/http/server.go:1824 +0x153
panic(0x165ba40, 0x2590670)
	/usr/local/go/src/runtime/panic.go:971 +0x499
github.com/lomik/graphite-clickhouse/render.writePB2(0xc0003fa060, 0xc0003fa0c0, 0xc00050a340, 0xc000050134, 0x32, 0xc0000fab80, 0x32, 0x607006a1606ff891, 0x0, 0xc0008da500, ...)
	/home/msv/go/src/github.com/lomik/graphite-clickhouse/render/pb2_writer.go:11 +0x71f
github.com/lomik/graphite-clickhouse/render.(*Handler).ReplyProtobuf.func1(0xc0008da500, 0x169, 0x18a)
	/home/msv/go/src/github.com/lomik/graphite-clickhouse/render/reply_protobuf.go:50 +0x210
github.com/lomik/graphite-clickhouse/render.(*Handler).ReplyProtobuf(0xc0000e87d8, 0x1c2c970, 0xc000182000, 0xc000328800, 0x0, 0x0, 0xc000c4f5a8, 0x1, 0x1, 0x1831e00)
	/home/msv/go/src/github.com/lomik/graphite-clickhouse/render/reply_protobuf.go:67 +0x3f5
github.com/lomik/graphite-clickhouse/render.(*Handler).Reply(0xc0000e87d8, 0x1c2c970, 0xc000182000, 0xc000328800, 0x0, 0x0, 0xc000c4f5a8, 0x1, 0x1)
	/home/msv/go/src/github.com/lomik/graphite-clickhouse/render/handler.go:171 +0x46e
github.com/lomik/graphite-clickhouse/render.(*Handler).ServeHTTP(0xc0000e87d8, 0x1c2c970, 0xc000182000, 0xc000328800)
	/home/msv/go/src/github.com/lomik/graphite-clickhouse/render/handler.go:160 +0xa39
main.Handler.func1(0x1c2cbe0, 0xc0002e8000, 0xc000328700)
	/home/msv/go/src/github.com/lomik/graphite-clickhouse/graphite-clickhouse.go:67 +0xdd
net/http.HandlerFunc.ServeHTTP(0xc000c4edb0, 0x1c2cbe0, 0xc0002e8000, 0xc000328700)
	/usr/local/go/src/net/http/server.go:2069 +0x44
net/http.(*ServeMux).ServeHTTP(0x25b7180, 0x1c2cbe0, 0xc0002e8000, 0xc000328700)
	/usr/local/go/src/net/http/server.go:2448 +0x1ad
net/http.serverHandler.ServeHTTP(0xc000156000, 0x1c2cbe0, 0xc0002e8000, 0xc000328700)
	/usr/local/go/src/net/http/server.go:2887 +0xa3
net/http.(*conn).serve(0xc00098e000, 0x1c30420, 0xc00021a580)
	/usr/local/go/src/net/http/server.go:1952 +0x8cd
created by net/http.(*Server).Serve
	/usr/local/go/src/net/http/server.go:3013 +0x39b

If needed, I can try to create test case with non-production data.

Interesting. Is it reproducible with pb3 as well?

BTW, since I can't really quick answer on GH last time, we have a telegram chat for discussions https://t.me/ru_go_graphite

Yes, with pb3 error was reproduce.