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

to_regrole produces 0 unexpectedly #124908

Open
r33s3n6 opened this issue May 31, 2024 · 2 comments
Open

to_regrole produces 0 unexpectedly #124908

r33s3n6 opened this issue May 31, 2024 · 2 comments
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community X-blathers-triaged blathers was able to find an owner

Comments

@r33s3n6
Copy link

r33s3n6 commented May 31, 2024

Describe the problem
to_regrole produced wrong result in single-node version but not in multi-node version

To Reproduce
init table first

create table t_w7ytodksh ( 
c_y1ghlp2 int4 ,
c_v5ud text not null ,
c_ofe4vtd2 float4 ,
primary key(c_y1ghlp2),
unique(c_y1ghlp2)
);

insert into t_w7ytodksh (c_y1ghlp2, c_v5ud, c_ofe4vtd2) values 
  (1418491921, 'i_p', cast(null as float4)), 
  (-2119060826, 'z_a', cast(null as float4)), 
  (1546925471, 'q160re', cast(null as float4)), 
  (-270885846, 'yi', cast(null as float4));

insert into t_w7ytodksh (c_y1ghlp2, c_v5ud, c_ofe4vtd2) values 
  (-2041433144, 'i809u1', 126.1), 
  (-1656729026, 'ro1hbc', cast(null as float4)), 
  (1611979541, 'vgg7', cast(null as float4)), 
  (-1320332968, 'btlsd6', cast(null as float4));
  

then execute:

SELECT
  pg_catalog.to_regrole(
    cast(pg_catalog.sha1(
      cast(ref_0.c_v5ud as char)) as char)) as c2
FROM
  t_w7ytodksh as ref_0;

Expected behavior
The multi-node version of CockroachDB produced incorrect results.

test=> SELECT
  pg_catalog.to_regrole(
    cast(pg_catalog.sha1(
      cast(ref_0.c_v5ud as char)) as char)) as c2
FROM
  t_w7ytodksh as ref_0;
 c2 
----
 
 
 
 
 
 
 
 
(8 rows)

The single-node version of CockroachDB produced incorrect results.

test=> SELECT
  pg_catalog.to_regrole(
    cast(pg_catalog.sha1(
      cast(ref_0.c_v5ud as char)) as char)) as c2
FROM
  t_w7ytodksh as ref_0;
 c2 
----
 
 0
 
 
 
 0
 
 
(8 rows)

0 should not be present in the result.

Environment:

  • CockroachDB version: 23.1.9
  • 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: postgresql odbc/psql

docker compose file:

version: '3.5'

services:
  crdb1:
    image: cockroachdb/cockroach:v23.1.19
    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: 10.0.5.11

  crdb2:
    image: cockroachdb/cockroach:v23.1.19
    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: 10.0.5.12

  crdb3:
    image: cockroachdb/cockroach:v23.1.19
    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: 10.0.5.13

  crdb_single:
    image: "cockroachdb/cockroach:v23.1.19"

    command: start-single-node --insecure
    volumes:
      - "crdb_single_data:/cockroach/cockroach-data"
    networks:
      crnet:
        ipv4_address: 10.0.5.21

volumes:
  crdb1_data:
  crdb2_data:
  crdb3_data:
  crdb_single_data:


networks:
  crnet:
    driver: bridge
    ipam:
      config:
        - subnet: 10.0.5.0/24
          gateway: 10.0.5.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-39146

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

blathers-crl bot commented May 31, 2024

Hi @r33s3n6, 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 May 31, 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-foundations (found keywords: pg_)

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 May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community X-blathers-triaged blathers was able to find an owner
Projects
None yet
Development

No branches or pull requests

1 participant