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.09k stars 3.8k forks source link

internal error: unable to vectorize execution plan #134043

Open r33s3n6 opened 2 hours ago

r33s3n6 commented 2 hours ago

Describe the problem internal error: unable to vectorize execution plan: incompatible value type: expected CAST(NULL AS TIMESTAMP) to be of type timestamptz, found type timestamp

To Reproduce

create table t0 (c1 float4);
insert into t0 values (1), (2), (3), (4), (5), (6);

SELECT
  '1'
FROM
  t0
WHERE
  (
    (case when ((select null) between 634165162 and -483114126) then cast(null as "timestamp") 
  else case when true then pg_catalog.clock_timestamp() 
        else ((cast(null as "interval")) + (cast(null as "timestamp"))) end
    end
      ) IS NOT DISTINCT FROM (cast(null as "timestamptz")))
;

error log:

ERROR:  internal error: unable to vectorize execution plan: CASE WHEN NULL AND NULL THEN CAST(NULL AS TIMESTAMP) ELSE clock_timestamp() END IS NOT DISTINCT FROM CAST(NULL AS TIMESTAMPTZ): incompatible value type: expected CAST(NULL AS TIMESTAMP) to be of type timestamptz, found type timestamp
DETAIL:  stack trace:
github.com/cockroachdb/cockroach/pkg/sql/execinfrapb/pkg/sql/execinfrapb/expr.go:267: deserializeExpr()
github.com/cockroachdb/cockroach/pkg/sql/execinfrapb/pkg/sql/execinfrapb/expr.go:242: prepareExpr()
github.com/cockroachdb/cockroach/pkg/sql/execinfrapb/pkg/sql/execinfrapb/expr.go:76: Init()
github.com/cockroachdb/cockroach/pkg/sql/rowexec/filterer.go:69: newFiltererProcessor()
github.com/cockroachdb/cockroach/pkg/sql/rowexec/processors.go:145: NewProcessor()
github.com/cockroachdb/cockroach/pkg/sql/colexec/colbuilder/execplan.go:539: func1()
github.com/cockroachdb/cockroach/pkg/sql/colexec/colbuilder/execplan.go:109: wrapRowSources()
github.com/cockroachdb/cockroach/pkg/sql/colexec/colbuilder/execplan.go:527: createAndWrapRowSource()
github.com/cockroachdb/cockroach/pkg/sql/colexec/colbuilder/execplan.go:1839: planAndMaybeWrapFilter()
github.com/cockroachdb/cockroach/pkg/sql/colexec/colbuilder/execplan.go:943: NewColOperator()
github.com/cockroachdb/cockroach/pkg/sql/colflow/vectorized_flow.go:1195: func1()
github.com/cockroachdb/cockroach/pkg/sql/colexecerror/error.go:152: CatchVectorizedRuntimeError()
github.com/cockroachdb/cockroach/pkg/sql/colflow/vectorized_flow.go:1134: setupFlow()
github.com/cockroachdb/cockroach/pkg/sql/colflow/vectorized_flow.go:260: Setup()
github.com/cockroachdb/cockroach/pkg/sql/distsql/server.go:411: setupFlow()
github.com/cockroachdb/cockroach/pkg/sql/distsql/server.go:639: func1()
github.com/cockroachdb/cockroach/pkg/sql/distsql/server.go:667: SetupFlow()
github.com/cockroachdb/cockroach/pkg/sql/execinfrapb/bazel-out/k8-opt/bin/pkg/sql/execinfrapb/execinfrapb_go_proto_/github.com/cockroachdb/cockroach/pkg/sql/execinfrapb/api.pb.go:597: func1()
github.com/cockroachdb/cockroach/pkg/util/tracing/grpcinterceptor/grpc_interceptor.go:97: func12()
google.golang.org/grpc/external/org_golang_google_grpc/server.go:1154: func1()
github.com/cockroachdb/cockroach/pkg/rpc/pkg/rpc/context.go:170: func3()
google.golang.org/grpc/external/org_golang_google_grpc/server.go:1154: func1()
github.com/cockroachdb/cockroach/pkg/rpc/pkg/rpc/context.go:137: 1()
github.com/cockroachdb/cockroach/pkg/util/stop/stopper.go:337: RunTaskWithErr()
github.com/cockroachdb/cockroach/pkg/rpc/pkg/rpc/context.go:135: func1()
google.golang.org/grpc/external/org_golang_google_grpc/server.go:1145: func1()
github.com/cockroachdb/cockroach/pkg/sql/execinfrapb/bazel-out/k8-opt/bin/pkg/sql/execinfrapb/execinfrapb_go_proto_/github.com/cockroachdb/cockroach/pkg/sql/execinfrapb/api.pb.go:599: _DistSQL_SetupFlow_Handler()
google.golang.org/grpc/external/org_golang_google_grpc/server.go:1335: processUnaryRPC()
google.golang.org/grpc/external/org_golang_google_grpc/server.go:1712: handleStream()
google.golang.org/grpc/external/org_golang_google_grpc/server.go:947: 1()
src/runtime/asm_amd64.s:1695: goexit()

Environment:

docker compose file:

x-service-defaults: &service_defaults
  image: cockroachdb/cockroach:v24.2.4

services:
  crdb1:
    <<: *service_defaults
    command: "start --advertise-addr=crdb1:26357 --http-addr=crdb1:8080 --listen-addr=crdb1:26357 --sql-addr=crdb1:26257 --insecure --join=crdb1:26357,crdb2:26357,crdb3:26357"
    volumes:
      - "crdb1_data:/cockroach/cockroach-data"
    networks:
      crnet:
        ipv4_address: ${CR_SUBNET}.11

  crdb2:
    <<: *service_defaults
    command: "start --advertise-addr=crdb2:26357 --http-addr=crdb2:8080 --listen-addr=crdb2:26357 --sql-addr=crdb2:26257 --insecure --join=crdb1:26357,crdb2:26357,crdb3:26357"
    volumes:
      - "crdb2_data:/cockroach/cockroach-data"
    networks:
      crnet:
        ipv4_address: ${CR_SUBNET}.12

  crdb3:
    <<: *service_defaults
    command: "start --advertise-addr=crdb3:26357 --http-addr=crdb3:8080 --listen-addr=crdb3:26357 --sql-addr=crdb3:26257 --insecure --join=crdb1:26357,crdb2:26357,crdb3:26357"
    volumes:
      - "crdb3_data:/cockroach/cockroach-data"
    networks:
      crnet:
        ipv4_address: ${CR_SUBNET}.13

  crdb_single:
    <<: *service_defaults
    command: start-single-node --insecure
    volumes:
      - "crdb_single_data:/cockroach/cockroach-data"
    networks:
      crnet:
        ipv4_address: ${CR_SUBNET}.21

volumes:
  crdb1_data:
  crdb2_data:
  crdb3_data:
  crdb_single_data:

networks:
  crnet:
    driver: bridge
    ipam:
      config:
        - subnet: ${CR_SUBNET:?please provide subnet range like `10.0.5`}.0/24
          gateway: ${CR_SUBNET}.254

about us We are the BASS team from the School of Cyber Science and Technology at Beihang University. Our main focus is on system software security, operating systems, and program analysis research, as well as the development of automated program testing frameworks for detecting software defects. Using our self-developed database vulnerability testing tool, we have identified the above-mentioned possible vulnerabilities that may lead to database internal error.

Jira issue: CRDB-43895

blathers-crl[bot] commented 2 hours ago

Hi @r33s3n6, 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 2 hours 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.