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

sql: Internal error when querying a REGIONAL BY ROW table during DROP REGION #64223

Closed
ajstorm opened this issue Apr 26, 2021 · 0 comments · Fixed by #64273
Closed

sql: Internal error when querying a REGIONAL BY ROW table during DROP REGION #64223

ajstorm opened this issue Apr 26, 2021 · 0 comments · Fixed by #64273
Assignees
Labels
A-multiregion Related to multi-region C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.

Comments

@ajstorm
Copy link
Collaborator

ajstorm commented Apr 26, 2021

If users query REGIONAL BY ROW tables while a background DROP REGION statement is occurring (more specifically, is in the schema changer), they may observe this:

ERROR: internal error: Optimize can only be called on relational root expressions
SQLSTATE: XX000
DETAIL: stack trace:
github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:775: optimizeRootWithProps()
github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:220: Optimize()
github.com/cockroachdb/cockroach/pkg/sql/plan_opt.go:525: buildExecMemo()
github.com/cockroachdb/cockroach/pkg/sql/plan_opt.go:194: makeOptimizerPlan()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:940: makeExecPlan()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:821: dispatchToExecutionEngine()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:659: execStmtInOpenState()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:122: execStmt()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1527: func1()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1529: execCmd()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1450: run()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:484: ServeConn()
github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:626: func1()
runtime/asm_amd64.s:1374: goexit()

HINT: You have encountered an unexpected error.

Please check the public issue tracker to check whether this problem is
already tracked. If you cannot find it there, please report the error
with details by creating a new issue.

If you would rather not post publicly, please contact us directly
using the support form.

We appreciate your feedback.

The query then fails, but is likely to succeed if reissued.

This occurs because under the covers, the query detects the system in a partial state - the crdb_internal_region enum doesn't have the enum value present anymore, but the underlying RBR table hasn't yet been repartitioned.

The fix for this problem is to ensure that queries can't find the system in this partial state.

@ajstorm ajstorm added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. A-multiregion Related to multi-region labels Apr 26, 2021
@ajstorm ajstorm self-assigned this Apr 26, 2021
@craig craig bot closed this as completed in 974b144 Apr 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-multiregion Related to multi-region C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant