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

Problem with several subqueries in one query #269

Closed
oizgagin opened this issue Feb 20, 2020 · 3 comments · Fixed by #278
Closed

Problem with several subqueries in one query #269

oizgagin opened this issue Feb 20, 2020 · 3 comments · Fixed by #278

Comments

@oizgagin
Copy link

Hi! Thanks for such a great project!

Problem

promxy v0.0.57 panics when given e.g. the folowing metric

deriv(avg_over_time(sum(node_cpu)[5m:1m])[5m:1m]) * 60

with traceback

goroutine 136 [running]:
github.com/jacksontj/promxy/pkg/proxystorage.(*ProxyStorage).NodeReplacer(0xc00021ca10, 0x273c8e0, 0xc000810100, 0xc0004d2320, 0x26e5cc0, 0xc0007e0cc0, 0xc0000a81e0, 0x0, 0xc000810100, 0x26e0000)
        /go/src/github.com/jacksontj/promxy/pkg/proxystorage/proxy.go:262 +0x31f2
github.com/jacksontj/promxy/vendor/github.com/prometheus/prometheus/promql.Walk(0x273c8e0, 0xc000810100, 0x26e8320, 0xc000810040, 0xc0004d2320, 0x26e5cc0, 0xc0007e0cc0, 0xc0008101c0, 0x3, 0x4, ...)
        /go/src/github.com/jacksontj/promxy/vendor/github.com/prometheus/prometheus/promql/ast.go:275 +0x186f
github.com/jacksontj/promxy/vendor/github.com/prometheus/prometheus/promql.Walk(0x273c8e0, 0xc000810100, 0x26e8320, 0xc000810040, 0xc0004d2320, 0x26e8300, 0xc000330a40, 0xc0008101c0, 0x3, 0x4, ...)
        /go/src/github.com/jacksontj/promxy/vendor/github.com/prometheus/prometheus/promql/ast.go:300 +0x430
github.com/jacksontj/promxy/vendor/github.com/prometheus/prometheus/promql.Walk(0x273c8e0, 0xc000810100, 0x26e8320, 0xc000810040, 0xc0004d2320, 0x26e5be0, 0xc0007de400, 0xc000330a20, 0x2, 0x2, ...)
        /go/src/github.com/jacksontj/promxy/vendor/github.com/prometheus/prometheus/promql/ast.go:355 +0x1518
github.com/jacksontj/promxy/vendor/github.com/prometheus/prometheus/promql.Walk.func1(0x273c8e0, 0xc000810100, 0x26e8320, 0xc000810040, 0xc0004d2320, 0xc00008d180, 0xc00021d240, 0xc0000d8a20, 0xc0000781e0, 0x1, ...)
        /go/src/github.com/jacksontj/promxy/vendor/github.com/prometheus/prometheus/promql/ast.go:328 +0xf1
created by github.com/jacksontj/promxy/vendor/github.com/prometheus/prometheus/promql.Walk
        /go/src/github.com/jacksontj/promxy/vendor/github.com/prometheus/prometheus/promql/ast.go:327 +0xd10

Possible solution

From my understanding, it should be ok to add another case to switch here:

diff --git a/pkg/proxystorage/proxy.go b/pkg/proxystorage/proxy.go
index 11386ba6..1e46139c 100644
--- a/pkg/proxystorage/proxy.go
+++ b/pkg/proxystorage/proxy.go
@@ -258,6 +258,8 @@ func (p *ProxyStorage) NodeReplacer(ctx context.Context, s *promql.EvalStmt, nod
                        n.Expr = promql.NewRawMatrixFromMatrix(subNodeTyped)
                case *promql.VectorSelector:
                        n.Expr = promql.NewRawMatrixFromVector(subNodeTyped)
+               case nil:
+                       break
                default:
                        panic(fmt.Sprintf("Unhandled SubqueryExpr return type: %T", subNode))
                }
@oizgagin
Copy link
Author

@jacksontj is there anything I can help you with?

jacksontj added a commit that referenced this issue Mar 4, 2020
Thanks to @oizgagin for reporting and debugging this one!

Fixes #269
@jacksontj
Copy link
Owner

@oizgagin Thanks for the report, debug, and fix! I've opened #278 with the fix (it looks correct to me), so once CI passes that'll get merged in.

jacksontj added a commit that referenced this issue Mar 4, 2020
Thanks to @oizgagin for reporting and debugging this one!

Fixes #269
@oizgagin
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants