yugabyte / yugabyte-db

YugabyteDB - the cloud native distributed SQL database for mission-critical applications.
https://www.yugabyte.com
Other
8.88k stars 1.05k forks source link

[YSQL] After executing statement with `!~`, server closed the connection unexpectedly. #24024

Open ycybfhb opened 1 day ago

ycybfhb commented 1 day ago

Jira Link: DB-12913

Description

Basic Information

Version:

PostgreSQL 11.2-YB-2.21.1.0-b0 on x86_64-pc-linux-gnu, compiled by clang version 17.0.6 (https://github.com/yugabyte/llvm-project.git 9b881774e40024e901fc6f3d313607b071c08631), 64-bit

Deploy:

version: '2'

volumes:
  yb-master-data-1:
  yb-tserver-data-1:
  yb-tserver-data-2:
  yb-tserver-data-3:

services:
  yb-master:
      image: yugabytedb/yugabyte:${YBVER:-latest}
      container_name: yb-master-n1
      volumes:
      - yb-master-data-1:/mnt/master
      tmpfs:
      - /tmp
      command: [ "/home/yugabyte/bin/yb-master",
                "--fs_data_dirs=/mnt/master",
                "--master_addresses=yb-master-n1:7100",
                "--rpc_bind_addresses=yb-master-n1:7100",
                "--replication_factor=1"]
      ports:
      - "7000:7000"
      networks:
        yb-net:
          ipv4_address: 10.1.3.11
      environment:
        SERVICE_7000_NAME: yb-master

  yb-tserver:
      image: yugabytedb/yugabyte:${YBVER:-latest}
      container_name: yb-tserver-n1
      volumes:
      - yb-tserver-data-1:/mnt/tserver
      tmpfs:
      - /tmp
      command: [ "/home/yugabyte/bin/yb-tserver",
                "--fs_data_dirs=/mnt/tserver",
                "--enable_ysql",
                "--rpc_bind_addresses=yb-tserver-n1:9100",
                "--tserver_master_addrs=yb-master-n1:7100"]
      environment:
        SERVICE_5433_NAME: ysql
        SERVICE_9042_NAME: ycql
        SERVICE_6379_NAME: yedis
        SERVICE_9000_NAME: yb-tserver
      depends_on:
      - yb-master
      networks:
        yb-net:
          ipv4_address: 10.1.3.21

  yb-tserver2:
      image: yugabytedb/yugabyte:${YBVER:-latest}
      container_name: yb-tserver-n2
      volumes:
      - yb-tserver-data-2:/mnt/tserver
      tmpfs:
      - /tmp
      command: [ "/home/yugabyte/bin/yb-tserver",
                "--fs_data_dirs=/mnt/tserver",
                "--enable_ysql",
                "--rpc_bind_addresses=yb-tserver-n2:9100",
                "--tserver_master_addrs=yb-master-n1:7100"]
      environment:
        SERVICE_5433_NAME: ysql
        SERVICE_9042_NAME: ycql
        SERVICE_6379_NAME: yedis
        SERVICE_9000_NAME: yb-tserver
      depends_on:
      - yb-master
      networks:
        yb-net:
          ipv4_address: 10.1.3.22

  yb-tserver3:
      image: yugabytedb/yugabyte:${YBVER:-latest}
      container_name: yb-tserver-n3
      volumes:
      - yb-tserver-data-3:/mnt/tserver
      tmpfs:
      - /tmp
      command: [ "/home/yugabyte/bin/yb-tserver",
                "--fs_data_dirs=/mnt/tserver",
                "--enable_ysql",
                "--rpc_bind_addresses=yb-tserver-n3:9100",
                "--tserver_master_addrs=yb-master-n1:7100"]
      environment:
        SERVICE_5433_NAME: ysql
        SERVICE_9042_NAME: ycql
        SERVICE_6379_NAME: yedis
        SERVICE_9000_NAME: yb-tserver
      depends_on:
      - yb-master
      networks:
        yb-net:
          ipv4_address: 10.1.3.23

networks:
  yb-net:
    driver: bridge
    enable_ipv6: false
    ipam:
      config:
        - subnet: 10.1.3.0/24
          gateway: 10.1.3.1

Reproduce

Firstly, connect to the database via the psql command.

Secondly, execute the statements in init.sql to create the tables.

Finally, when executing the following statements, a crash occurred, and the server closed the connection.

select 1 from t_r4otr31c_l as ref_11 where cast(ref_11.c_y7ry3r as text) !~ cast(ref_11.c_y7ry3r as text);
yb_main=> select 1 from t_r4otr31c_l as ref_11 where cast(ref_11.c_y7ry3r as text) !~ cast(ref_11.c_y7ry3r as text);
server closed the connection unexpectedly
    This probably means the server terminated abnormally
    before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.

init.sql: init.sql.txt

Docker Error Log

2024-09-19 09:08:43.137 UTC [93] HINT:  Future log output will appear in directory "/mnt/tserver/yb-data/tserver/logs".
*** Aborted at 1726736925 (unix time) try "date -d @1726736925" if you are using GNU date ***
PC: @                0x0 (unknown)
*** SIGSEGV (@0x0) received by PID 7 (TID 0x7f5439800700) from PID 0; stack trace: ***
    @     0x55783a6d9790 RE_compile_and_cache
    @     0x55783a6d9d9e textregexne
    @     0x55783a79b3bb evalExpr
    @     0x55783a79b01d YbgEvalExpr
    @     0x557838b5be6f yb::docdb::DocPgEvalExpr()
    @     0x557838b067d7 yb::docdb::DocPgExprExecutor::State::Exec()
    @     0x557838ba3122 yb::docdb::(anonymous namespace)::FilteringIterator::CheckFilter()
    @     0x557838ba1c05 yb::docdb::(anonymous namespace)::FilteringIterator::FetchNext()
    @     0x557838b9eaac yb::docdb::PgsqlReadOperation::Execute()
    @     0x55783993c46c yb::tablet::Tablet::HandlePgsqlReadRequest()
    @     0x557839bc7be7 yb::tserver::(anonymous namespace)::ReadQuery::Complete()
    @     0x557839bc24ad yb::tserver::PerformRead()
    @     0x557839c2f052 yb::tserver::TabletServiceImpl::Read()
    @     0x557839dd95ab std::__1::__function::__func<>::operator()()
    @     0x557839ddb61f yb::tserver::TabletServerServiceIf::Handle()
    @     0x557839867ce9 yb::rpc::ServicePoolImpl::Handle()
    @     0x5578397846ff yb::rpc::InboundCall::InboundCallTask::Run()
    @     0x5578398774e3 yb::rpc::(anonymous namespace)::Worker::Execute()
    @     0x55783a09a0b3 yb::Thread::SuperviseThread()
    @     0x7f548e1f91ca start_thread
    @     0x7f548e44a8d3 __GI___clone

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 vulnerabilities in Yugabyte that may lead to database crashes.

Issue Type

kind/bug

Warning: Please confirm that this issue does not contain any sensitive information

ycybfhb commented 1 day ago

Hello, I can still reproduce this crash on the version of PostgreSQL 11.2-YB-2.23.0.0-b0.

FranckPachot commented 1 day ago

Thanks for reporting. Looks like a bug in expression pushdown. Workaround: set yb_enable_expression_pushdown = off