cockroachdb / cockroachdb/cockroach
`->>` produced different result between distributed execution and local execution.
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
**Describe the problem**
`->>` produced different result between distributed execution and local execution.
**To Reproduce**
For distributed execution:
```sql
create table t1 (a1 int8);
alter table t1 configure zone using num_replicas = 1, constraints = '[+region=r2]';
insert into t1 values (0), (1);
select
a1,
pg_catalog.to_json('NaN'::float8),
pg_catalog.to_json('NaN'::float8) ->> a1
from t1
;
```
For local execution:
```sql
create table t1 (a1 int8);
--- alter table t1 configure zone using num_replicas = 1, constraints = '[+region=r2]';
insert into t1 values (0), (1);
select
a1,
pg_catalog.to_json('NaN'::float8),
pg_catalog.to_json('NaN'::float8) ->> a1
from t1
;
```
**Result (distributed execution)**:
```
a1 | to_json | ?column?
----+---------+----------
0 | "NaN" | NaN
1 | "NaN" |
(2 rows)
```
**Result (local execution)**:
```
a1 | to_json | ?column?
----+---------+----------
0 | "NaN" | "NaN"
1 | "NaN" |
(2 rows)
```
**distributed plan**
```
planning time: 549µs
execution time: 3ms
distribution: full
vectorized: true
plan type: custom
rows decoded from KV: 2 (78 B, 1 gRPC calls)
cumulative time spent in KV: 1ms
maximum memory usage: 50 KiB
network usage: 624 B (4 messages)
regions: r1, r2
sql cpu time: 173µs
isolation level: serializable
priority: normal
quality of service: regular
• render
│
└── • scan
nodes: n2
regions: r2
actual row count: 2
KV time: 1ms
KV contention time: 0µs
KV rows decoded: 2
KV bytes read: 78 B
KV gRPC calls: 1
estimated max memory allocated: 20 KiB
sql cpu time: 56µs
missing stats
table: t1@t1_pkey
spans: FULL SCAN
(31 rows)
```
**local plan**
```
planning time: 667µs
execution time: 1ms
distribution: full
vectorized: true
plan type: custom
rows decoded from KV: 2 (78 B, 1 gRPC calls)
cumulative time spent in KV: 954µs
maximum memory usage: 30 KiB
network usage: 0 B (0 messages)
sql cpu time: 58µs
isolation level: serializable
priority: normal
quality of service: regular
• render
│
└── • scan
nodes: n1
actual row count: 2
KV time: 954µs
KV contention time: 0µs
KV rows decoded: 2
KV bytes read: 78 B
KV gRPC calls: 1
estimated max memory allocated: 20 KiB
sql cpu time: 58µs
missing stats
table: t1@t1_pkey
spans: FULL SCAN
(29 rows)
```
**Environment:**
- CockroachDB version: 23.2.23
- Server OS: `Linux a002 6.5.0-18-generic #18~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 7 11:40:03 UTC 2 x86_64 x86_64 x86_64 GNU/Linux`
- Client app: psql
docker compose file:
```
x-service-defaults: &service_defaults
image: ${CR_IMAGE:?please provide the image name}
services:
crdb1:
<<: *service_defaults
command: "start --advertise-addr=crdb1:26357 --locality=region=r1,zone=r1a --http-addr=crdb1:8080 --listen-addr=crdb1:26357 --sql-addr=crdb1:26257 --insecure --join=crdb1:26357,crdb2:26357,crdb3:26357,crdb4:26357,crdb5:26357"
volumes:
- "/cockroach/cockroach-data"
networks:
crnet:
ipv4_address: ${CR_SUBNET}.11
crdb2:
<<: *service_defaults
command: "start --advertise-addr=crdb2:26357 --locality=region=r2,zone=r2a --http-addr=crdb2:8080 --listen-addr=crdb2:26357 --sql-addr=crdb2:26257 --insecure --join=crdb1:26357,crdb2:26357,crdb3:26357,crdb4:26357,crdb5:26357"
volumes:
- "/cockroach/cockroach-data"
networks:
crnet:
ipv4_address: ${CR_SUBNET}.12
crdb3:
<<: *service_defaults
command: "start --advertise-addr=crdb3:26357 --locality=region=r3,zone=r3a --http-addr=crdb3:8080 --listen-addr=crdb3:26357 --sql-addr=crdb3:26257 --insecure --join=crdb1:26357,crdb2:26357,crdb3:26357,crdb4:26357,crdb5:26357"
volumes:
- "/cockroach/cockroach-data"
networks:
crnet:
ipv4_address: ${CR_SUBNET}.13
crdb4:
<<: *service_defaults
command: "start --advertise-addr=crdb4:26357 --locality=region=r4,zone=r4a --http-addr=crdb4:8080 --listen-addr=crdb4:26357 --sql-addr=crdb4:26257 --insecure --join=crdb1:26357,crdb2:26357,crdb3:26357,crdb4:26357,crdb5:26357"
volumes:
- "/cockroach/cockroach-data"
networks:
crnet:
ipv4_address: ${CR_SUBNET}.14
crdb5:
<<: *service_defaults
command: "start --advertise-addr=crdb5:26357 --locality=region=r5,zone=r5a --http-addr=crdb5:8080 --listen-addr=crdb5:26357 --sql-addr=crdb5:26257 --insecure --join=crdb1:26357,crdb2:26357,crdb3:26357,crdb4:26357,crdb5:26357"
volumes:
- "/cockroach/cockroach-data"
networks:
crnet:
ipv4_address: ${CR_SUBNET}.15
crdb_single:
<<: *service_defaults
command: start-single-node --insecure
volumes:
- "/cockroach/cockroach-data"
networks:
crnet:
ipv4_address: ${CR_SUBNET}.21
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 logic error.
Jira issue: CRDB-49567
Contributor guide
Assessment
This issue has not been assessed yet.