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 with BUCKET_COUNT = NULL #130353

Closed
SteveLeungYL opened this issue Sep 9, 2024 · 3 comments · Fixed by #131212
Closed

sql: internal error with BUCKET_COUNT = NULL #130353

SteveLeungYL opened this issue Sep 9, 2024 · 3 comments · Fixed by #131212
Labels
branch-release-23.1 Used to mark GA and release blockers, technical advisories, and bugs for 23.1 branch-release-23.2 Used to mark GA and release blockers, technical advisories, and bugs for 23.2 branch-release-24.1 Used to mark GA and release blockers, technical advisories, and bugs for 24.1 branch-release-24.2 Used to mark GA and release blockers, technical advisories, and bugs for 24.2 C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. E-quick-win Likely to be a quick win for someone experienced. 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

@SteveLeungYL
Copy link

SteveLeungYL commented Sep 9, 2024

Describe the problem

The latest version of the CockroachDB (60313dc or v24.2.1) crashes when executing the following query:

CREATE TABLE v0 ( c1 INT PRIMARY KEY USING HASH WITH BUCKET_COUNT = NULL ); 

To Reproduce

  1. In operating system Ubuntu 20.04 LTS, download the CockroachDB source code from the github source.
  2. Download the pre-build CockroachDB binaries (v24.2.1) from link
  3. Run ./cockroach demo, and then paste the PoC query to the cockroach cli environment.
  4. Observe the Internal Error and log the stack information.

Expected behavior

The Create Table statement execution should return error:

ERROR: BUCKET_COUNT must be a strictly positive integer value
SQLSTATE: 22023

Additional data / screenshots

Here is the crash stack trace from CockroachDB v24.2.1:

*
* ERROR: Queued as error 8f2291d5cb21444685d4c2f998a99100
*
ERROR: internal error: expected *DInt, found tree.dNull
SQLSTATE: XX000
DETAIL: stack trace:
github.com/cockroachdb/cockroach/pkg/sql/sem/tree/datum.go:686: MustBeDInt()
github.com/cockroachdb/cockroach/pkg/sql/catalog/tabledesc/table.go:298: EvalShardBucketCount()
github.com/cockroachdb/cockroach/pkg/sql/create_table.go:1604: NewTableDesc()
github.com/cockroachdb/cockroach/pkg/sql/create_table.go:2385: func1()
github.com/cockroachdb/cockroach/pkg/sql/schema_resolver.go:444: runWithOptions()
github.com/cockroachdb/cockroach/pkg/sql/create_table.go:2384: newTableDesc()
github.com/cockroachdb/cockroach/pkg/sql/create_table.go:397: 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: func2()
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()

Environment:

  • CockroachDB version: v24.2.1
  • Server OS: Ubuntu 20.04 LTS
  • Client app: CockroachDB demo command. (./cockroach demo)
  • Detailed CockroachDB version output:
cockroach version details:
Build Tag:        v24.2.1
Build Time:       2024/09/04 02:31:53
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:  b95f17a1ddc0676a7cd64c1a0e3415cd85c221ba
Build Type:       release
Enabled Assertions: false

Jira issue: CRDB-42013

Epic CRDB-40419

@SteveLeungYL SteveLeungYL added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Sep 9, 2024
Copy link

blathers-crl bot commented Sep 9, 2024

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

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

Copy link

blathers-crl bot commented Sep 9, 2024

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 Sep 9, 2024
@rytaft rytaft added the T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) label Sep 9, 2024
@mgartner mgartner changed the title sql: CockroachDB crashes with BUCKET_COUNT = NULL sql: internal error with BUCKET_COUNT = NULL Sep 9, 2024
@mgartner
Copy link
Collaborator

mgartner commented Sep 9, 2024

This bug was introduced in v20.2. Prior to that, it errored gracefully. In v20.1.19:

defaultdb> CREATE TABLE v0 ( c1 INT PRIMARY KEY USING HASH WITH BUCKET_COUNT = NULL );
ERROR: BUCKET_COUNT must be a strictly positive integer value
SQLSTATE: 22023

@fqazi fqazi added the E-quick-win Likely to be a quick win for someone experienced. label Sep 10, 2024
@exalate-issue-sync exalate-issue-sync bot removed the E-quick-win Likely to be a quick win for someone experienced. label Sep 10, 2024
@exalate-issue-sync exalate-issue-sync bot added E-quick-win Likely to be a quick win for someone experienced. branch-release-24.2 Used to mark GA and release blockers, technical advisories, and bugs for 24.2 labels Sep 18, 2024
vidit-bhat added a commit to vidit-bhat/cockroach that referenced this issue Sep 23, 2024
Previously, the `EvalShardBucketCount` function did
not properly handle the case where `BUCKET_COUNT` was
set to `NULL`, causing evaluation errors. This change
adds explicit handling for `NULL` values, ensuring that
`BUCKET_COUNT` cannot be set to `NULL` and returns an
appropriate error message.

Also added a check for NULL before sanitizing and evaluating shardBuckets
to avoid invalid operations on NULL values.
returns the error `BUCKET_COUNT cannot be NULL`.

Epic: none
Fixes: cockroachdb#130353
Release note: None
@spilchen spilchen added branch-release-24.1 Used to mark GA and release blockers, technical advisories, and bugs for 24.1 branch-release-23.1 Used to mark GA and release blockers, technical advisories, and bugs for 23.1 branch-release-23.2 Used to mark GA and release blockers, technical advisories, and bugs for 23.2 labels Sep 25, 2024
vidit-bhat added a commit to vidit-bhat/cockroach that referenced this issue Sep 25, 2024
Previously, the `EvalShardBucketCount` function did
not properly handle the case where `BUCKET_COUNT` was
set to `NULL`, causing evaluation errors. This change
adds explicit handling for `NULL` values, ensuring that
`BUCKET_COUNT` cannot be set to `NULL` and returns an
appropriate error message.

Also added a check for NULL before sanitizing and evaluating shardBuckets
to avoid invalid operations on NULL values.
returns the error `BUCKET_COUNT cannot be NULL`.

Epic: none
Fixes: cockroachdb#130353
Release note: None
craig bot pushed a commit that referenced this issue Sep 26, 2024
131212: sql: internal error with BUCKET_COUNT = NULL r=spilchen a=vidit-bhat

Previously, the `EvalShardBucketCount` function did not properly handle the case where `BUCKET_COUNT` was set to `NULL`, causing evaluation errors. This change adds explicit handling for `NULL` values, ensuring that `BUCKET_COUNT` cannot be set to `NULL` and returns an appropriate error message.

Epic: none
Fixes: #130353
Release note: None

Co-authored-by: Vidit Bhat <[email protected]>
@craig craig bot closed this as completed in 1bdef16 Sep 26, 2024
blathers-crl bot pushed a commit that referenced this issue Sep 30, 2024
Previously, the `EvalShardBucketCount` function did
not properly handle the case where `BUCKET_COUNT` was
set to `NULL`, causing evaluation errors. This change
adds explicit handling for `NULL` values, ensuring that
`BUCKET_COUNT` cannot be set to `NULL` and returns an
appropriate error message.

Also added a check for NULL before sanitizing and evaluating shardBuckets
to avoid invalid operations on NULL values.
returns the error `BUCKET_COUNT cannot be NULL`.

Epic: none
Fixes: #130353
Release note: None
blathers-crl bot pushed a commit that referenced this issue Sep 30, 2024
Previously, the `EvalShardBucketCount` function did
not properly handle the case where `BUCKET_COUNT` was
set to `NULL`, causing evaluation errors. This change
adds explicit handling for `NULL` values, ensuring that
`BUCKET_COUNT` cannot be set to `NULL` and returns an
appropriate error message.

Also added a check for NULL before sanitizing and evaluating shardBuckets
to avoid invalid operations on NULL values.
returns the error `BUCKET_COUNT cannot be NULL`.

Epic: none
Fixes: #130353
Release note: None
blathers-crl bot pushed a commit that referenced this issue Sep 30, 2024
Previously, the `EvalShardBucketCount` function did
not properly handle the case where `BUCKET_COUNT` was
set to `NULL`, causing evaluation errors. This change
adds explicit handling for `NULL` values, ensuring that
`BUCKET_COUNT` cannot be set to `NULL` and returns an
appropriate error message.

Also added a check for NULL before sanitizing and evaluating shardBuckets
to avoid invalid operations on NULL values.
returns the error `BUCKET_COUNT cannot be NULL`.

Epic: none
Fixes: #130353
Release note: None
blathers-crl bot pushed a commit that referenced this issue Sep 30, 2024
Previously, the `EvalShardBucketCount` function did
not properly handle the case where `BUCKET_COUNT` was
set to `NULL`, causing evaluation errors. This change
adds explicit handling for `NULL` values, ensuring that
`BUCKET_COUNT` cannot be set to `NULL` and returns an
appropriate error message.

Also added a check for NULL before sanitizing and evaluating shardBuckets
to avoid invalid operations on NULL values.
returns the error `BUCKET_COUNT cannot be NULL`.

Epic: none
Fixes: #130353
Release note: None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
branch-release-23.1 Used to mark GA and release blockers, technical advisories, and bugs for 23.1 branch-release-23.2 Used to mark GA and release blockers, technical advisories, and bugs for 23.2 branch-release-24.1 Used to mark GA and release blockers, technical advisories, and bugs for 24.1 branch-release-24.2 Used to mark GA and release blockers, technical advisories, and bugs for 24.2 C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. E-quick-win Likely to be a quick win for someone experienced. 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
None yet
Development

Successfully merging a pull request may close this issue.

5 participants