cockroachdb / cockroach

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
https://www.cockroachlabs.com
Other
30.11k stars 3.81k forks source link

sql: Internal Error when using incorrect type in REVOKE statement #131157

Closed SteveLeungYL closed 1 week ago

SteveLeungYL commented 1 month ago

Describe the problem

The latest version of the CockroachDB v24.2.0 encounters Internal Error when executing the following query:

CREATE TABLE t0 (c1 INT);
GRANT ALL ON ALL TABLES IN SCHEMA public TO current_user;
REVOKE CREATE ON SEQUENCE t0 FROM current_user;

To Reproduce

  1. In operating system Ubuntu 20.04 LTS, download the pre-build CockroachDB binaries (v24.2.0) from link
  2. Run ./cockroach demo, and then paste the PoC query to the cockroach cli environment.
  3. Observe the crash and log the stack information.

Expected behavior The CockroachDB should return error from the REVOKE statement.

Additional data / screenshots

This is the stack frame from the crash (v24.2.0):

ERROR: internal error: user demo must not have [USAGE] privileges on table "t0"
SQLSTATE: XX000
DETAIL: stack trace:
github.com/cockroachdb/cockroach/pkg/sql/catalog/catpb/pkg/sql/catalog/catpb/privilege.go:420: Validate()
github.com/cockroachdb/cockroach/pkg/sql/catalog/catprivilege/validate.go:27: Validate()
github.com/cockroachdb/cockroach/pkg/sql/grant_revoke.go:357: startExec()
github.com/cockroachdb/cockroach/pkg/sql/plan.go:524: func2()
github.com/cockroachdb/cockroach/pkg/sql/walk.go:112: func1()
github.com/cockroachdb/cockroach/pkg/sql/walk.go:299: 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:527: startExec()
github.com/cockroachdb/cockroach/pkg/sql/plan_node_to_row_source.go:171: Start()
github.com/cockroachdb/cockroach/pkg/sql/colexec/columnarizer.go:183: Init()
github.com/cockroachdb/cockroach/pkg/sql/colflow/stats.go:94: init()
github.com/cockroachdb/cockroach/pkg/sql/colexecerror/error.go:152: CatchVectorizedRuntimeError()
github.com/cockroachdb/cockroach/pkg/sql/colflow/stats.go:103: Init()
github.com/cockroachdb/cockroach/pkg/sql/colflow/flow_coordinator.go:241: func1()
github.com/cockroachdb/cockroach/pkg/sql/colexecerror/error.go:152: CatchVectorizedRuntimeError()
github.com/cockroachdb/cockroach/pkg/sql/colflow/flow_coordinator.go:240: init()
github.com/cockroachdb/cockroach/pkg/sql/colflow/flow_coordinator.go:274: Run()
github.com/cockroachdb/cockroach/pkg/sql/colflow/vectorized_flow.go:320: Run()
github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:932: Run()
github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:1994: PlanAndRun()
github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:1708: func3()
github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:1711: PlanAndRunAll()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:2420: execWithDistSQLEngine()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:1967: dispatchToExecutionEngine()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:1174: execStmtInOpenState()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:146: func1()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:3429: execWithProfiling()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:145: execStmt()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:2316: func1()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:2321: execCmd()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:2238: run()

HINT: You have encountered an unexpected error.

Environment:

cockroach version details:
Build Tag:        v24.2.0
Build Time:       2024/08/08 01:50:30
Distribution:     CCL
Platform:         linux arm64 (aarch64-unknown-linux-gnu)
Go Version:       go1.22.5 X:nocoverageredesign
C Compiler:       gcc 6.5.0
Build Commit ID:  953d09cce5a01cc0053e138516d80a27454f027c
Build Type:       release

Jira issue: CRDB-42413

Epic CRDB-43310

blathers-crl[bot] commented 1 month ago

Hi @SteveLeungYL, please add branch-* labels to identify which branch(es) this C-bug affects.

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

blathers-crl[bot] commented 1 month ago

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:

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

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

blathers-crl[bot] commented 1 week ago

Based on the specified backports for linked PR #133607, I applied the following new label(s) to this issue: branch-release-23.1, branch-release-23.2, branch-release-24.1, branch-release-24.3. Please adjust the labels as needed to match the branches actually affected by this issue, including adding any known older branches.

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