Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-35793

Server crashes in Item_func_vec_distance_common::get_const_arg

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • 11.7(EOL)
    • 11.7.2
    • Vector search
    • None

    Description

      --source include/have_innodb.inc
       
      create table t (pk int primary key, v vector(1) not null, vector(v)) engine=innodb;
      insert into t values (1,0x31313131),(2,0x32323232); # optional, fails either way
      select distinct vec_distance_euclidean(v, 0x30303030) as d from t order by pk;
      drop table t;
      

      11.7 bc32705f46fa93d9700a20c8d439e48e5c352272

      #3  <signal handler called>
      #4  0x00005587cceb0755 in Item_func_vec_distance_common::get_const_arg (this=0x6290000fbba8) at /data/bld/11.7-asan/sql/item_vectorfunc.h:52
      #5  0x00005587cceab882 in mhnsw_read_first (table=0x6190000cc698, keyinfo=0x6190000cd170, dist=0x6290000fbba8, limit=10000) at /data/bld/11.7-asan/sql/vector_mhnsw.cc:1254
      #6  0x00005587cbf22326 in TABLE::hlindex_read_first (this=0x6190000cc698, nr=1, item=0x6290000fbba8, limit=18446744073709551615) at /data/bld/11.7-asan/sql/sql_base.cc:9998
      #7  0x00005587cc266603 in join_read_first (tab=0x6290002ee238) at /data/bld/11.7-asan/sql/sql_select.cc:25207
      #8  0x00005587cc25de47 in sub_select (join=0x6290000fbf50, join_tab=0x6290002ee238, end_of_records=false) at /data/bld/11.7-asan/sql/sql_select.cc:24093
      #9  0x00005587cc25b88d in do_select (join=0x6290000fbf50, procedure=0x0) at /data/bld/11.7-asan/sql/sql_select.cc:23607
      #10 0x00005587cc1d72fc in JOIN::exec_inner (this=0x6290000fbf50) at /data/bld/11.7-asan/sql/sql_select.cc:5037
      #11 0x00005587cc1d4666 in JOIN::exec (this=0x6290000fbf50) at /data/bld/11.7-asan/sql/sql_select.cc:4820
      #12 0x00005587cc1d8db5 in mysql_select (thd=0x62c0001e0218, tables=0x6290000fabe0, fields=..., conds=0x0, og_num=1, order=0x6290000fbcf0, group=0x0, having=0x0, proc_param=0x0, select_options=2164525825, result=0x6290000fbf20, unit=0x62c0001e4740, select_lex=0x6290000fa340) at /data/bld/11.7-asan/sql/sql_select.cc:5353
      #13 0x00005587cc1a7119 in handle_select (thd=0x62c0001e0218, lex=0x62c0001e4660, result=0x6290000fbf20, setup_tables_done_option=0) at /data/bld/11.7-asan/sql/sql_select.cc:633
      #14 0x00005587cc0c9370 in execute_sqlcom_select (thd=0x62c0001e0218, all_tables=0x6290000fabe0) at /data/bld/11.7-asan/sql/sql_parse.cc:6177
      #15 0x00005587cc0b8f64 in mysql_execute_command (thd=0x62c0001e0218, is_called_from_prepared_stmt=false) at /data/bld/11.7-asan/sql/sql_parse.cc:3966
      #16 0x00005587cc0d3e02 in mysql_parse (thd=0x62c0001e0218, rawbuf=0x6290000fa238 "select distinct vec_distance_euclidean(v, 0x30303030) as d from t order by pk", length=77, parser_state=0x7ff12327ca30) at /data/bld/11.7-asan/sql/sql_parse.cc:7901
      #17 0x00005587cc0aad7d in dispatch_command (command=COM_QUERY, thd=0x62c0001e0218, packet=0x629000280219 "", packet_length=77, blocking=true) at /data/bld/11.7-asan/sql/sql_parse.cc:1903
      #18 0x00005587cc0a7a85 in do_command (thd=0x62c0001e0218, blocking=true) at /data/bld/11.7-asan/sql/sql_parse.cc:1416
      #19 0x00005587cc59e6cb in do_handle_one_connection (connect=0x608000004c38, put_in_cache=true) at /data/bld/11.7-asan/sql/sql_connect.cc:1415
      #20 0x00005587cc59e22a in handle_one_connection (arg=0x608000004bb8) at /data/bld/11.7-asan/sql/sql_connect.cc:1327
      #21 0x00005587cd25c6bc in pfs_spawn_thread (arg=0x617000008218) at /data/bld/11.7-asan/storage/perfschema/pfs.cc:2198
      #22 0x00007ff1322a8044 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
      #23 0x00007ff13232861c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
      

      Also fails with GROUP BY instead of DISTINCT.
      On 11.8 it is Item_func_vec_distance::get_const_arg instead of Item_func_vec_distance_common::get_const_arg.

      Attachments

        Issue Links

          Activity

            commit b8bae4b85365f574f46e2ff137657065d14a1978 (HEAD -> bb-11.7-MDEV-35793, origin/bb-11.7-MDEV-35793)
            Author: Oleksandr Byelkin <sanja@mariadb.com>
            Date:   Fri Jan 17 08:42:17 2025 +0100
             
                MDEV-35793: Server crashes in Item_func_vec_distance_common::get_const_arg
                
                The problem was that vector index was used for grouping to avoid DISTINCT
                and also other ORDER BY was present and we guess wrongly where vector
                index used.
                
                So now we save ORDER class used for ordering by index in JOIN_TAB instead
                of guessing it.
            

            sanja Oleksandr Byelkin added a comment - commit b8bae4b85365f574f46e2ff137657065d14a1978 (HEAD -> bb-11.7-MDEV-35793, origin/bb-11.7-MDEV-35793) Author: Oleksandr Byelkin <sanja@mariadb.com> Date: Fri Jan 17 08:42:17 2025 +0100   MDEV-35793: Server crashes in Item_func_vec_distance_common::get_const_arg The problem was that vector index was used for grouping to avoid DISTINCT and also other ORDER BY was present and we guess wrongly where vector index used. So now we save ORDER class used for ordering by index in JOIN_TAB instead of guessing it.

            Review input provided on Slack. Ok to push after addressed.

            psergei Sergei Petrunia added a comment - Review input provided on Slack. Ok to push after addressed.

            People

              sanja Oleksandr Byelkin
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.