Skip to content

Return subquery errors instead of panicking on unnest into query - #7715

Open
jay23606 wants to merge 1 commit into
superdb:mainfrom
jay23606:pr-go/7396-panic-on-unnest-expr-into-query-with-non
Open

jay23606 wants to merge 1 commit into
superdb:mainfrom
jay23606:pr-go/7396-panic-on-unnest-expr-into-query-with-non

Conversation

@jay23606

Copy link
Copy Markdown

Bug

unnest [1] into (from "http://127.0.0.1:1/x" (format json)) panicked when the source could not be reached (#7396). The compile-time path in compileVamSubquery already returned errors, but the callback that re-creates a subquery instance for re-entrant evaluation still called panic(err), and the first compile also panicked on the same error class.

Change

  • runtime/op/subquery.go: NewSubquery now takes a create callback that returns (*Subquery, error). Subquery.Eval returns the error as an error value when it cannot create a duplicate instance, instead of panicking.
  • compiler/rungen/vexpr.go: the re-creation callback passes the error through; the panic is removed.
  • runtime/ztests/expr/subquery-into-connect-error.yaml: regression test. It checks that super fails with the error text and does not panic. It matches the stable prefix http://127.0.0.1:1/x: Get "...": dial tcp 127.0.0.1:1: so it does not depend on the OS-specific connect message (Windows reports a different string).

Testing

  • go build ./runtime/op/ ./compiler/... && go vet ./runtime/op/ ./compiler/rungen/ passes.
  • The regression test passes on this fix and fails on the parent commit with panic: http://127.0.0.1:1/x: Get ..., as the issue describes.
  • The re-creation path is not covered by a dedicated test. Reaching it needs a re-entrant subquery whose source fails only on a later instance, which I did not construct.

Regression test: fails on base twice (/panic: http://127\.0\.0\.1:1/x/), passes on fix twice (mkdir -p .pr-go/bin && go build -o .pr-go/bin/super ./cmd/super && ZTEST_PATH="$PWD/.pr-go/bin" go test . -short -run 'TestSPQ/runtime/ztests/expr/subquery-into-connect-error')

Fixes #7396

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 this pull request may close these issues.

Panic on "unnest <expr> into ( <query> )" with non-listening URL

1 participant