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

sqlsmith: nil pointer in tryBuildOpaque during ALTER TABLE DROP COLUMN CASCADE #99764

Closed
cockroach-teamcity opened this issue Mar 28, 2023 · 3 comments · Fixed by #100750
Closed
Assignees
Labels
branch-master Failures and bugs on the master branch. branch-release-23.1 Used to mark GA and release blockers, technical advisories, and bugs for 23.1 C-test-failure Broken test (automatically or manually discovered). GA-blocker O-roachtest O-robot Originated from a bot. T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Milestone

Comments

@cockroach-teamcity
Copy link
Member

cockroach-teamcity commented Mar 28, 2023

roachtest.sqlsmith/setup=empty/setting=default failed with artifacts on release-23.1 @ 3551dc089ac3efcb3772df2109164dcb01e79d8f:

test artifacts and logs in: /artifacts/sqlsmith/setup=empty/setting=default/run_1
(sqlsmith.go:244).func3: error: pq: internal error: building declarative schema change targets for ALTER TABLE: runtime error: invalid memory address or nil pointer dereference
stmt:
ALTER TABLE defaultdb.public.tab454 DROP COLUMN "co l0_3" CASCADE;

Parameters: ROACHTEST_cloud=gce , ROACHTEST_cpu=4 , ROACHTEST_encrypted=false , ROACHTEST_ssd=0

Help

See: roachtest README

See: How To Investigate (internal)

Same failure on other branches

/cc @cockroachdb/sql-queries

This test on roachdash | Improve this report!

Jira issue: CRDB-26058

@cockroach-teamcity cockroach-teamcity added branch-release-23.1 Used to mark GA and release blockers, technical advisories, and bugs for 23.1 C-test-failure Broken test (automatically or manually discovered). O-roachtest O-robot Originated from a bot. labels Mar 28, 2023
@cockroach-teamcity cockroach-teamcity added this to the 23.1 milestone Mar 28, 2023
@blathers-crl blathers-crl bot added the T-sql-queries SQL Queries Team label Mar 28, 2023
@michae2 michae2 self-assigned this Mar 28, 2023
@michae2
Copy link
Collaborator

michae2 commented Mar 30, 2023

Reduced to:

SET sql_safe_updates = off;

CREATE TABLE tab26 (
  "c
    ol0_2"      BYTES,
  "co l0_3"      TIMETZ,
  "col😏0%p_4" REGROLE,
  col0_5         TIMESTAMPTZ,
  "cOl0_7"       GEOGRAPHY[],
  "c'oL0_8"      BOOL,
  col0_12        CHAR,
  "-col0_14"     DATE NOT NULL,
  UNIQUE ("co l0_3" ASC, lower(CAST("co l0_3" AS STRING)) ASC)
);

ALTER TABLE tab26 RENAME TO tab454;

ALTER TABLE tab454 DROP COLUMN "co l0_3" CASCADE;

@michae2
Copy link
Collaborator

michae2 commented Mar 30, 2023

Further reduced to:

SET sql_safe_updates = off;
CREATE TABLE t (
  col TIMETZ,
  UNIQUE (col, CAST(col AS STRING))
);
ALTER TABLE t DROP COLUMN col CASCADE;

Error is:

> ALTER TABLE t DROP COLUMN col CASCADE;
ERROR: internal error: building declarative schema change targets for ALTER TABLE: runtime error: invalid memory address or nil pointer dereference
SQLSTATE: XX000
DETAIL: stack trace:
github.com/cockroachdb/cockroach/pkg/util/errorutil/catch.go:29: ShouldCatch()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:209: func1()
GOROOT/src/runtime/panic.go:884: gopanic()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/opaque.go:72: tryBuildOpaque()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:425: buildStmt()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:269: buildStmtAtRoot()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:243: Build()
github.com/cockroachdb/cockroach/pkg/sql/plan_opt.go:573: buildExecMemo()
github.com/cockroachdb/cockroach/pkg/sql/plan_opt.go:237: makeOptimizerPlan()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:1640: makeExecPlan()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:1246: dispatchToExecutionEngine()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:770: execStmtInOpenState()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:137: func1()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:2660: execWithProfiling()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:136: execStmt()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:2117: func1()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:2122: execCmd()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:2038: run()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:867: ServeConn()
github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:738: func1()
GOROOT/src/runtime/asm_amd64.s:1594: goexit()

@michae2 michae2 changed the title roachtest: sqlsmith/setup=empty/setting=default failed sqlsmith: nil pointer in tryBuildOpaque during ALTER TABLE DROP COLUMN CASCADE Mar 30, 2023
@blathers-crl blathers-crl bot added the T-sql-schema-deprecated Use T-sql-foundations instead label Mar 30, 2023
@michae2 michae2 removed the T-sql-queries SQL Queries Team label Mar 30, 2023
@michae2 michae2 removed their assignment Mar 30, 2023
@michae2 michae2 added the branch-master Failures and bugs on the master branch. label Mar 30, 2023
@ajwerner
Copy link
Contributor

ajwerner commented Apr 4, 2023

@Xiang-Gu can you have a look?

craig bot pushed a commit that referenced this issue Apr 6, 2023
100651: roachtest/version-upgrade: re-enable schema changer workload r=fqazi a=fqazi

Previously, the schema changer workload was disabled inside the version upgrade test because of intermittent job errors. This patch re-enables this workload again for the version upgrade test. It also updates the test to handle mixed version declarative schema changer support.

Fixes: #100409

Release note: None

100750: schemachanger: fixed a bug dropping a column used in expression index r=rafiss a=Xiang-Gu

Previously, if we are dropping a column used in an index that includes other columns, we will hit a nil-pointer dereference error. The root cause here is that we might be dropping the same secondary index twice without enough "idempotency" checks.

Epic: None
Fixes: #99764
Release note (bug fix): Fixed a bug where dropping a column cascade when that column is used in an index that involves other expression column caused a panic.

100836: build: pass `-fno-use-linker-plugin` to compiler r=rail,herkolategan a=rickystewart

The missing flag here was causing builds of krb5 to fail.

Epic: none
Release note: None

Co-authored-by: Faizan Qazi <[email protected]>
Co-authored-by: Xiang Gu <[email protected]>
Co-authored-by: Ricky Stewart <[email protected]>
@craig craig bot closed this as completed in b47610b Apr 6, 2023
blathers-crl bot pushed a commit that referenced this issue Apr 6, 2023
Previously, if we are dropping a column used in an index that includes
other columns, we will hit a nil-pointer dereference error. This PR
fixes that.

Epic: None
Fixes: #99764
Release note (bug fix): Fixed a bug where dropping a column cascade when
that column is used in an index that involves other expression column
caused a panic.
Xiang-Gu added a commit to Xiang-Gu/cockroach that referenced this issue Apr 10, 2023
Previously, if we are dropping a column used in an index that includes
other columns, we will hit a nil-pointer dereference error. This PR
fixes that.

Epic: None
Fixes: cockroachdb#99764
Release note (bug fix): Fixed a bug where dropping a column cascade when
that column is used in an index that involves other expression column
caused a panic.
@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
branch-master Failures and bugs on the master branch. branch-release-23.1 Used to mark GA and release blockers, technical advisories, and bugs for 23.1 C-test-failure Broken test (automatically or manually discovered). GA-blocker O-roachtest O-robot Originated from a bot. T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants