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

internal error about index #100681

Closed
DerZc opened this issue Apr 5, 2023 · 7 comments
Closed

internal error about index #100681

DerZc opened this issue Apr 5, 2023 · 7 comments
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) X-blathers-triaged blathers was able to find an owner

Comments

@DerZc
Copy link

DerZc commented Apr 5, 2023

Describe the problem
The following program triggers an internal error:

CREATE DATABASE database4;
USE database4;

CREATE TABLE t0 (c0 BIT(98), c1 BYTES[]);
CREATE TABLE t1 (c0 BOOL);
CREATE INDEX ON t1(c0);
CREATE INDEX ON t1(c0);
CREATE INDEX ON t1(c0);

CREATE VIEW v0(c0) AS SELECT NULL FROM t0 CROSS JOIN t1 @{FORCE_INDEX=t1_c0_idx2,DESC};
TRUNCATE t1 RESTRICT;

This is the error message:

> TRUNCATE t1 RESTRICT;
ERROR: internal error: relation "t1" (1596): index ID 6 found in depended-on-by references, no such index in this relation
SQLSTATE: XX000
DETAIL: stack trace:
github.com/cockroachdb/cockroach/pkg/sql/catalog/tabledesc/validate.go:633: ValidateSelf()
github.com/cockroachdb/cockroach/pkg/sql/catalog/internal/validate/validate.go:71: func1()
github.com/cockroachdb/cockroach/pkg/sql/catalog/internal/validate/validate.go:189: validateDescriptorsAtLevel()
github.com/cockroachdb/cockroach/pkg/sql/catalog/internal/validate/validate.go:67: Validate()
github.com/cockroachdb/cockroach/pkg/sql/catalog/internal/validate/validate.go:41: Self()
github.com/cockroachdb/cockroach/pkg/sql/catalog/tabledesc/structured.go:602: AllocateIDs()
github.com/cockroachdb/cockroach/pkg/sql/truncate.go:218: truncateTable()
github.com/cockroachdb/cockroach/pkg/sql/truncate.go:128: startExec()
github.com/cockroachdb/cockroach/pkg/sql/plan.go:518: func2()
github.com/cockroachdb/cockroach/pkg/sql/walk.go:112: func1()
github.com/cockroachdb/cockroach/pkg/sql/walk.go:297: visitInternal()
github.com/cockroachdb/cockroach/pkg/sql/walk.go:79: visit()
github.com/cockroachdb/cockroach/pkg/sql/walk.go:43: walkPlan()
github.com/cockroachdb/cockroach/pkg/sql/plan.go:521: startExec()
github.com/cockroachdb/cockroach/pkg/sql/plan_node_to_row_source.go:166: Start()
github.com/cockroachdb/cockroach/pkg/sql/colexec/columnarizer.go:187: Init()
github.com/cockroachdb/cockroach/pkg/sql/colflow/stats.go:92: init()
github.com/cockroachdb/cockroach/pkg/sql/colexecerror/error.go:92: CatchVectorizedRuntimeError()
github.com/cockroachdb/cockroach/pkg/sql/colflow/stats.go:101: Init()
github.com/cockroachdb/cockroach/pkg/sql/colflow/flow_coordinator.go:247: func1()
github.com/cockroachdb/cockroach/pkg/sql/colexecerror/error.go:92: CatchVectorizedRuntimeError()
github.com/cockroachdb/cockroach/pkg/sql/colflow/flow_coordinator.go:246: init()
github.com/cockroachdb/cockroach/pkg/sql/colflow/flow_coordinator.go:291: Run()
github.com/cockroachdb/cockroach/pkg/sql/colflow/vectorized_flow.go:320: Run()
github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:733: Run()
github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:1728: PlanAndRun()
github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:1445: PlanAndRunAll()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:1587: execWithDistSQLEngine()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:1201: dispatchToExecutionEngine()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:696: execStmtInOpenState()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:131: func1()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:2428: execWithProfiling()

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.

I build cockroach from the last commit in github repo (ff2c4a3), but this bug can reproduce with the last release version v22.2.7.

I run cockroach in a single machine, and execute the query with CLI cockroach sql --echo-sql --insecure --port 26257 --user root < database4.sql

Expected behavior
No error.

Environment:

  • CockroachDB version [last commit version and last release version v22.2.7]
  • Server OS: [ubuntu 22.04]
  • Client app [CLI]

Jira issue: CRDB-26552

@DerZc DerZc added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Apr 5, 2023
@blathers-crl
Copy link

blathers-crl bot commented Apr 5, 2023

Hello, I am Blathers. I am here to help you get the issue triaged.

Hoot - a bug! Though bugs are the bane of my existence, rest assured the wretched thing will get the best of care here.

I have CC'd a few people who may be able to assist you:

  • @cockroachdb/sql-queries (found keywords: Vectorized,distsql,plan)

If we have not gotten back to your issue within a few business days, you can try the following:

  • Join our community slack channel and ask on #cockroachdb.
  • Try find someone from here if you know they worked closely on the area and CC them.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@blathers-crl blathers-crl bot added O-community Originated from the community X-blathers-triaged blathers was able to find an owner labels Apr 5, 2023
@mgartner mgartner added this to Triage in SQL Foundations via automation Apr 5, 2023
@mgartner
Copy link
Collaborator

mgartner commented Apr 5, 2023

cc @cockroachdb/sql-schema

@blathers-crl blathers-crl bot added the T-sql-schema-deprecated Use T-sql-foundations instead label Apr 5, 2023
@fqazi
Copy link
Collaborator

fqazi commented Apr 5, 2023

This is a flaw in our truncate implementation we should be rewriting DependedOnBy entries within the table. The cases which are vulnerable have to use specific index hints like the one used in the reproduction case. The right thing to do here is to rewrite the dependencies within the table when recreating the indexes.

@DerZc Good find!

@yuzefovich
Copy link
Member

I think it's a dup of a known issue #85230. @fqazi I'll let you close this one if so.

@fqazi
Copy link
Collaborator

fqazi commented Apr 5, 2023

Yeah, this is a dup of #85230

@fqazi fqazi closed this as completed Apr 5, 2023
SQL Foundations automation moved this from Triage to Done Apr 5, 2023
@DerZc
Copy link
Author

DerZc commented Apr 5, 2023

So sorry about this, I will ckeck it more carefully

@yuzefovich
Copy link
Member

yuzefovich commented Apr 5, 2023

So sorry about this, I will ckeck it more carefully

No worries! Please feel free to not spend much time looking for duplicates, and we'll triage the issue accordingly.

@exalate-issue-sync exalate-issue-sync bot added T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) and removed T-sql-schema-deprecated Use T-sql-foundations instead labels May 10, 2023
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. O-community Originated from the community T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) X-blathers-triaged blathers was able to find an owner
Projects
Development

No branches or pull requests

4 participants