Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ingester crashes on invalid regex query #949

Closed
rfratto opened this issue Aug 28, 2019 · 1 comment
Closed

Ingester crashes on invalid regex query #949

rfratto opened this issue Aug 28, 2019 · 1 comment
Labels
type/bug Somehing is not working as expected

Comments

@rfratto
Copy link
Member

rfratto commented Aug 28, 2019

All ingesters will crash given a malformed regex label query like {cluster=~"*"}:

panic: error parsing regexp: missing argument to repetition operator: `*`

goroutine 18549256 [running]:
github.com/grafana/loki/pkg/logql.mustNewMatcher(0x2, 0xc0513f0ca0, 0x7, 0xc0513f0ca8, 0x1, 0x10)
	/go/src/github.com/grafana/loki/pkg/logql/ast.go:126 +0x8a
github.com/grafana/loki/pkg/logql.(*exprParserImpl).Parse(0xc02d3c6000, 0x17da140, 0xc061006580, 0x0)
	pkg/logql/expr.y:63 +0x10d6
github.com/grafana/loki/pkg/logql.ParseExpr(0xc0513f0c80, 0xe, 0xc0003a0e40, 0xc05105ab8a, 0x2, 0xc0000242f8)
	/go/src/github.com/grafana/loki/pkg/logql/parser.go:31 +0x1dc
github.com/grafana/loki/pkg/ingester.(*instance).Query(0xc000662300, 0xc0176f4d80, 0x17f8620, 0xc019c231f0, 0x0, 0x0)
	/go/src/github.com/grafana/loki/pkg/ingester/instance.go:124 +0x57
github.com/grafana/loki/pkg/ingester.(*Ingester).Query(0xc00021c000, 0xc0176f4d80, 0x17f8620, 0xc019c231f0, 0xc00021c000, 0xc017d4b6f8)
	/go/src/github.com/grafana/loki/pkg/ingester/ingester.go:198 +0xbe
github.com/grafana/loki/pkg/logproto._Querier_Query_Handler(0x15cc160, 0xc00021c000, 0x17f78a0, 0xc057aa2e60, 0xc057aa2e60, 0xc017d4b788)
	/go/src/github.com/grafana/loki/pkg/logproto/logproto.pb.go:1802 +0x109
github.com/grafana/loki/vendor/github.com/grpc-ecosystem/go-grpc-middleware.ChainStreamServer.func1.1(0x15cc160, 0xc00021c000, 0x17f78a0, 0xc057aa2e60, 0x17ee000, 0xc014eb7ec0)
	/go/src/github.com/grafana/loki/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:71 +0xf5
github.com/grafana/loki/vendor/github.com/weaveworks/common/middleware.StreamServerUserHeaderInterceptor(0x15cc160, 0xc00021c000, 0x17f6fa0, 0xc057aa2e40, 0xc057aa2da0, 0xc05d13eaf0, 0x1521180, 0x17ee001)
	/go/src/github.com/grafana/loki/vendor/github.com/weaveworks/common/middleware/grpc_auth.go:48 +0xfe
github.com/grafana/loki/vendor/github.com/grpc-ecosystem/go-grpc-middleware.ChainStreamServer.func1.1(0x15cc160, 0xc00021c000, 0x17f6fa0, 0xc057aa2e40, 0x17ee000, 0xc014eb7e90)
	/go/src/github.com/grafana/loki/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:74 +0x9c
github.com/grafana/loki/vendor/github.com/opentracing-contrib/go-grpc.OpenTracingStreamServerInterceptor.func1(0x15cc160, 0xc00021c000, 0x17f72a0, 0xc09616f140, 0xc057aa2da0, 0xc05d13eaf0, 0x0, 0x0)
	/go/src/github.com/grafana/loki/vendor/github.com/opentracing-contrib/go-grpc/server.go:114 +0x336
github.com/grafana/loki/vendor/github.com/grpc-ecosystem/go-grpc-middleware.ChainStreamServer.func1.1(0x15cc160, 0xc00021c000, 0x17f72a0, 0xc09616f140, 0x0, 0x1)
	/go/src/github.com/grafana/loki/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:74 +0x9c
github.com/grafana/loki/vendor/github.com/weaveworks/common/middleware.StreamServerInstrumentInterceptor.func1(0x15cc160, 0xc00021c000, 0x17f72a0, 0xc09616f140, 0xc057aa2da0, 0xc05d13eaf0, 0x5d669608, 0x39ee8d57)
	/go/src/github.com/grafana/loki/vendor/github.com/weaveworks/common/middleware/grpc_instrumentation.go:36 +0x9d
github.com/grafana/loki/vendor/github.com/grpc-ecosystem/go-grpc-middleware.ChainStreamServer.func1.1(0x15cc160, 0xc00021c000, 0x17f72a0, 0xc09616f140, 0xc02d640000, 0xc085654b80)
	/go/src/github.com/grafana/loki/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:74 +0x9c
github.com/grafana/loki/vendor/github.com/weaveworks/common/middleware.GRPCServerLog.StreamServerInterceptor(0x17fc8c0, 0xc0003dba10, 0x0, 0x15cc160, 0xc00021c000, 0x17f72a0, 0xc09616f140, 0xc057aa2da0, 0xc05d13eaf0, 0xc057aa2d01, ...)
	/go/src/github.com/grafana/loki/vendor/github.com/weaveworks/common/middleware/grpc_logging.go:48 +0x98
github.com/grafana/loki/vendor/github.com/weaveworks/common/middleware.GRPCServerLog.StreamServerInterceptor-fm(0x15cc160, 0xc00021c000, 0x17f72a0, 0xc09616f140, 0xc057aa2da0, 0xc05d13eaf0, 0xc085654c30, 0x40c558)
	/go/src/github.com/grafana/loki/vendor/github.com/weaveworks/common/server/server.go:136 +0x8a
github.com/grafana/loki/vendor/github.com/grpc-ecosystem/go-grpc-middleware.ChainStreamServer.func1(0x15cc160, 0xc00021c000, 0x17f72a0, 0xc09616f140, 0xc057aa2da0, 0x1661398, 0x0, 0x1)
	/go/src/github.com/grafana/loki/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:79 +0x14d
github.com/grafana/loki/vendor/google.golang.org/grpc.(*Server).processStreamingRPC(0xc000421800, 0x17fc0a0, 0xc000957800, 0xc0748f6e00, 0xc0005b4390, 0x24ef260, 0x0, 0x0, 0x0)
	/go/src/github.com/grafana/loki/vendor/google.golang.org/grpc/server.go:1209 +0x488
github.com/grafana/loki/vendor/google.golang.org/grpc.(*Server).handleStream(0xc000421800, 0x17fc0a0, 0xc000957800, 0xc0748f6e00, 0x0)
	/go/src/github.com/grafana/loki/vendor/google.golang.org/grpc/server.go:1282 +0xd9b
github.com/grafana/loki/vendor/google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc00e7c4b90, 0xc000421800, 0x17fc0a0, 0xc000957800, 0xc0748f6e00)
	/go/src/github.com/grafana/loki/vendor/google.golang.org/grpc/server.go:717 +0x9f
created by github.com/grafana/loki/vendor/google.golang.org/grpc.(*Server).serveStreams.func1
	/go/src/github.com/grafana/loki/vendor/google.golang.org/grpc/server.go:715 +0xa1
rfratto added a commit to rfratto/loki that referenced this issue Aug 29, 2019
loqgl.ParseExpr has been modified to use a defer/recover to recover from
a panic caused by a failed regex parse in the parser.

A defer and panic were used over adding an error return into
mustNewMatcher by imitating how Go's parser works[1]: the exposed
interface returns an error while the internal mechanisms use panic. This
simplifies the design and implementation of the parser.

Closes grafana#949.

[1]: https://golang.org/src/go/parser/interface.go#L92
@rfratto
Copy link
Member Author

rfratto commented Sep 5, 2019

Fixed by #654

@rfratto rfratto closed this as completed Sep 5, 2019
@chaudum chaudum added the type/bug Somehing is not working as expected label Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Somehing is not working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants