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: can't create a view/sequence inside a multi-region database #61382

Closed
arulajmani opened this issue Mar 3, 2021 · 0 comments
Closed

sql: can't create a view/sequence inside a multi-region database #61382

arulajmani opened this issue Mar 3, 2021 · 0 comments
Assignees
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. GA-blocker

Comments

@arulajmani
Copy link
Collaborator

Describe the problem

Multi-region databases require tables inside them to have a valid locality config which is enforced through validation. We don't disambiguate based on the descriptor type (views/sequences/tables) when validating this though. As the multi-region syntax is only available for tables, view/sequence descriptors aren't created with a locality config. This fails validation, meaning currently, it is impossible to create views/sequences inside of a multi-region database.

To Reproduce

[email protected]:26257/movr> CREATE DATABASE db PRIMARY REGION "us-east3";
CREATE DATABASE

Time: 15ms total (execution 15ms / network 0ms)

[email protected]:26257/movr> USE db;
SET

Time: 2ms total (execution 2ms / network 0ms)

[email protected]:26257/db> CREATE SEQUENCE seq;
ERROR: internal error: desc 63: invalid locality config: database db is multi-region enabled, but table seq has no locality set
SQLSTATE: XX000
DETAIL: stack trace:
github.com/cockroachdb/cockroach/pkg/sql/catalog/tabledesc/structured.go:1341: validateCrossReferences()
github.com/cockroachdb/cockroach/pkg/sql/catalog/tabledesc/structured.go:1272: Validate()
github.com/cockroachdb/cockroach/pkg/sql/create_sequence.go:155: doCreateSequence()
github.com/cockroachdb/cockroach/pkg/sql/create_sequence.go:79: startExec()
github.com/cockroachdb/cockroach/pkg/sql/plan.go:498: func2()
github.com/cockroachdb/cockroach/pkg/sql/walk.go:119: func1()
github.com/cockroachdb/cockroach/pkg/sql/walk.go:296: visitInternal()
github.com/cockroachdb/cockroach/pkg/sql/walk.go:86: visit()
github.com/cockroachdb/cockroach/pkg/sql/walk.go:50: walkPlan()
github.com/cockroachdb/cockroach/pkg/sql/plan.go:501: startExec()
github.com/cockroachdb/cockroach/pkg/sql/plan_node_to_row_source.go:126: Start()
github.com/cockroachdb/cockroach/pkg/sql/colexec/columnarizer.go:135: Init()
github.com/cockroachdb/cockroach/pkg/sql/colexecerror/error.go:91: CatchVectorizedRuntimeError()
github.com/cockroachdb/cockroach/pkg/sql/colexec/materializer.go:245: Start()
github.com/cockroachdb/cockroach/pkg/sql/execinfra/processorsbase.go:764: Run()
github.com/cockroachdb/cockroach/pkg/sql/flowinfra/flow.go:382: Run()
github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:367: Run()
github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:981: PlanAndRun()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:1036: execWithDistSQLEngine()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:908: dispatchToExecutionEngine()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:652: execStmtInOpenState()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:120: execStmt()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1502: func1()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1504: execCmd()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1429: run()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:483: ServeConn()
github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:625: func1()

Expected behavior
It should be possible to create a view/sequence inside a multi-region database.

@arulajmani arulajmani added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Mar 3, 2021
craig bot pushed a commit that referenced this issue Mar 17, 2021
62050: sql: allow VIEW and SEQUENCEs for multi-region databases r=ajstorm a=otan

Refs #61382 -- missing materialized views.

Release note (bug fix): Allow VIEWs and SEQUENCEs in multi-region
databases. They will have REGIONAL BY TABLE set.



Co-authored-by: Oliver Tan <[email protected]>
craig bot pushed a commit that referenced this issue Mar 18, 2021
62122: sql: set locality to GLOBAL for materialized views r=ajstorm a=otan

Only last two commits matter.
See individual commits for details.

Refs: #61382 


Co-authored-by: Oliver Tan <[email protected]>
@otan otan closed this as completed Mar 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. GA-blocker
Projects
None yet
Development

No branches or pull requests

3 participants