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

Assertion `fixed == 1' failed after the 2.nd execution of ps, query with ORDER BY (window function)

    XMLWordPrintable

    Details

      Description

      -- source include/have_innodb.inc
      create table t1 ( pk int not null primary key) engine=innodb;
      insert into t1 values (1);
       
      prepare stmt from "SELECT 1 FROM t1 ORDER BY BIT_AND(pk) OVER (), COUNT(1) OVER ()";
      execute stmt;
      execute stmt;
      drop table t1;
      

      also the same with stored procedures

      10.2 259e5243faa88370b

      #3  <signal handler called>
      #4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
      #5  0x00007f5a75fc0859 in __GI_abort () at abort.c:79
      #6  0x00007f5a75fc0729 in __assert_fail_base (fmt=0x7f5a76156588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x559ad0cf34cb "fixed == 1", file=0x559ad0cf3a88 "/10.2/src/sql/item_sum.cc", line=1648, function=<optimized out>) at assert.c:92
      #7  0x00007f5a75fd1f36 in __GI___assert_fail (assertion=0x559ad0cf34cb "fixed == 1", file=0x559ad0cf3a88 "/10.2/src/sql/item_sum.cc", line=1648, function=0x559ad0cf3e40 "virtual longlong Item_sum_count::val_int()") at assert.c:101
      #8  0x0000559ad04c6ff7 in Item_sum_count::val_int (this=0x7f5a18088758) at /10.2/src/sql/item_sum.cc:1648
      #9  0x0000559ad05cfb0d in Item_window_func::val_int (this=0x7f5a18088900) at /10.2/src/sql/item_windowfunc.h:903
      #10 0x0000559ad040c65c in Item::save_in_field (this=0x7f5a18088900, field=0x0, no_conversions=true) at /10.2/src/sql/item.cc:6419
      #11 0x0000559ad0336c38 in save_window_function_values (window_functions=..., tbl=0x7f5a18038e48, rowid_buf=0x7f5a18031570 "\020\253\003\030Z\177") at /10.2/src/sql/sql_window.cc:2534
      #12 0x0000559ad03370fd in compute_window_func (thd=0x7f5a18000d90, window_functions=..., cursor_managers=..., tbl=0x7f5a18038e48, filesort_result=0x7f5a18193090) at /10.2/src/sql/sql_window.cc:2679
      #13 0x0000559ad03374da in Window_func_runner::exec (this=0x7f5a18014d40, thd=0x7f5a18000d90, tbl=0x7f5a18038e48, filesort_result=0x7f5a18193090) at /10.2/src/sql/sql_window.cc:2782
      #14 0x0000559ad0337600 in Window_funcs_sort::exec (this=0x7f5a18014d38, join=0x7f5a180128d8, keep_filesort_result=false) at /10.2/src/sql/sql_window.cc:2810
      #15 0x0000559ad0337afa in Window_funcs_computation::exec (this=0x7f5a18014d18, join=0x7f5a180128d8, keep_last_filesort_result=false) at /10.2/src/sql/sql_window.cc:2937
      #16 0x0000559ad01e9520 in AGGR_OP::end_send (this=0x7f5a18014ba8) at /10.2/src/sql/sql_select.cc:26850
      #17 0x0000559ad01d3f75 in sub_select_postjoin_aggr (join=0x7f5a180128d8, join_tab=0x7f5a18013e80, end_of_records=true) at /10.2/src/sql/sql_select.cc:18574
      #18 0x0000559ad01d42a9 in sub_select (join=0x7f5a180128d8, join_tab=0x7f5a18013ad0, end_of_records=true) at /10.2/src/sql/sql_select.cc:18810
      #19 0x0000559ad01d3a8d in do_select (join=0x7f5a180128d8, procedure=0x0) at /10.2/src/sql/sql_select.cc:18405
      #20 0x0000559ad01ad6ab in JOIN::exec_inner (this=0x7f5a180128d8) at /10.2/src/sql/sql_select.cc:3642
      #21 0x0000559ad01acb52 in JOIN::exec (this=0x7f5a180128d8) at /10.2/src/sql/sql_select.cc:3437
      #22 0x0000559ad01add14 in mysql_select (thd=0x7f5a18000d90, tables=0x7f5a18087a90, wild_num=0, fields=..., conds=0x0, og_num=2, order=0x7f5a18088668, group=0x0, having=0x0, proc_param=0x0, select_options=2416184064, result=0x7f5a18088a38, unit=0x7f5a18086340, select_lex=0x7f5a18086a80) at /10.2/src/sql/sql_select.cc:3837
      #23 0x0000559ad01a1e8e in handle_select (thd=0x7f5a18000d90, lex=0x7f5a18086280, result=0x7f5a18088a38, setup_tables_done_option=0) at /10.2/src/sql/sql_select.cc:361
      #24 0x0000559ad016c539 in execute_sqlcom_select (thd=0x7f5a18000d90, all_tables=0x7f5a18087a90) at /10.2/src/sql/sql_parse.cc:6275
      #25 0x0000559ad01630ad in mysql_execute_command (thd=0x7f5a18000d90) at /10.2/src/sql/sql_parse.cc:3586
      #26 0x0000559ad018e977 in Prepared_statement::execute (this=0x7f5a180068b0, expanded_query=0x7f5a702dd980, open_cursor=false) at /10.2/src/sql/sql_prepare.cc:5053
      #27 0x0000559ad018ce80 in Prepared_statement::execute_loop (this=0x7f5a180068b0, expanded_query=0x7f5a702dd980, open_cursor=false, packet=0x0, packet_end=0x0) at /10.2/src/sql/sql_prepare.cc:4482
      #28 0x0000559ad018ab80 in mysql_sql_stmt_execute (thd=0x7f5a18000d90) at /10.2/src/sql/sql_prepare.cc:3574
      #29 0x0000559ad01630f2 in mysql_execute_command (thd=0x7f5a18000d90) at /10.2/src/sql/sql_parse.cc:3602
      #30 0x0000559ad01702e1 in mysql_parse (thd=0x7f5a18000d90, rawbuf=0x7f5a180126f8 "execute stmt", length=12, parser_state=0x7f5a702de570, is_com_multi=false, is_next_command=false) at /10.2/src/sql/sql_parse.cc:7790
      #31 0x0000559ad015e51e in dispatch_command (command=COM_QUERY, thd=0x7f5a18000d90, packet=0x7f5a18008b51 "", packet_length=12, is_com_multi=false, is_next_command=false) at /10.2/src/sql/sql_parse.cc:1827
      #32 0x0000559ad015d019 in do_command (thd=0x7f5a18000d90) at /10.2/src/sql/sql_parse.cc:1381
      #33 0x0000559ad02b7a7a in do_handle_one_connection (connect=0x559ad2af6ad0) at /10.2/src/sql/sql_connect.cc:1336
      #34 0x0000559ad02b77df in handle_one_connection (arg=0x559ad2af6ad0) at /10.2/src/sql/sql_connect.cc:1241
      #35 0x0000559ad0ae0a7a in pfs_spawn_thread (arg=0x559ad2ad9f40) at /10.2/src/storage/perfschema/pfs.cc:1869
      #36 0x00007f5a764e3609 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #37 0x00007f5a760bd293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      
      

      And then a lot of variations, depending on which functions to use:

      10.5 1f1f61a9de0c85ed5fbe1

      mariadbd: /10.5/sql/item_func.cc:5242: virtual my_decimal* Item_func_set_user_var::val_decimal(my_decimal*): Assertion `fixed == 1' failed.
       
      sql/item_func.cc:5243(Item_func_set_user_var::val_decimal(my_decimal*))[0x55ecc0f77031]
      sql/item_sum.cc:1807(Aggregator_simple::arg_val_decimal(my_decimal*))[0x55ecc106feaa]
      sql/item_sum.cc:1629(Item_sum_sum::add_helper(bool))[0x55ecc106e13a]
      sql/item_sum.cc:1602(Item_sum_sum::add())[0x55ecc106db8b]
      sql/sql_window.cc:1102(Frame_cursor::add_value_to_items())[0x55ecc0bfec03]
      sql/sql_window.cc:1515(Frame_range_current_row_bottom::pre_next_partition(unsigned long long))[0x55ecc0c012c1]
      sql/sql_window.cc:1162(Cursor_manager::notify_cursors_partition_changed(unsigned long long))[0x55ecc0bff355]
      sql/sql_window.cc:2845(compute_window_func(THD*, List<Item_window_func>&, List<Cursor_manager>&, TABLE*, SORT_INFO*))[0x55ecc0bfa34f]
      sql/sql_window.cc:2976(Window_func_runner::exec(THD*, TABLE*, SORT_INFO*))[0x55ecc0bfab58]
      sql/sql_window.cc:3004(Window_funcs_sort::exec(JOIN*, bool))[0x55ecc0bfada6]
      sql/sql_window.cc:3131(Window_funcs_computation::exec(JOIN*, bool))[0x55ecc0bfbbae]
      sql/sql_select.cc:28962(AGGR_OP::end_send())[0x55ecc07763f0]
      sql/sql_select.cc:20397(sub_select_postjoin_aggr(JOIN*, st_join_table*, bool))[0x55ecc0735b13]
      sql/sql_select.cc:20632(sub_select(JOIN*, st_join_table*, bool))[0x55ecc07364c6]
      sql/sql_select.cc:20223(do_select(JOIN*, Procedure*))[0x55ecc0734f08]
      sql/sql_select.cc:4467(JOIN::exec_inner())[0x55ecc06c16b9]
      sql/sql_select.cc:4248(JOIN::exec())[0x55ecc06beca4]
      sql/sql_select.cc:4722(mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*))[0x55ecc06c3078]
      sql/sql_select.cc:417(handle_select(THD*, LEX*, select_result*, unsigned long))[0x55ecc06948b6]
      sql/sql_parse.cc:6282(execute_sqlcom_select(THD*, TABLE_LIST*))[0x55ecc05fe024]
      sql/sql_parse.cc:3978(mysql_execute_command(THD*))[0x55ecc05ecf1f]
      sql/sql_prepare.cc:5007(Prepared_statement::execute(String*, bool))[0x55ecc065d384]
      sql/sql_prepare.cc:4470(Prepared_statement::execute_loop(String*, bool, unsigned char*, unsigned char*))[0x55ecc065888d]
      sql/sql_prepare.cc:3569(mysql_sql_stmt_execute(THD*))[0x55ecc06525c7]
      sql/sql_parse.cc:3995(mysql_execute_command(THD*))[0x55ecc05ecf64]
      sql/sql_parse.cc:8063(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x55ecc060931e]
      sql/sql_parse.cc:1892(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x55ecc05df517]
      sql/sql_parse.cc:1370(do_command(THD*))[0x55ecc05dbe40]
      sql/sql_connect.cc:1410(do_handle_one_connection(CONNECT*, bool))[0x55ecc0a1e6dc]
      sql/sql_connect.cc:1314(handle_one_connection)[0x55ecc0a1e040]
      perfschema/pfs.cc:2203(pfs_spawn_thread)[0x55ecc172dbf7]
      nptl/pthread_create.c:478(start_thread)[0x7f5f8cd55609]
      x86_64/clone.S:97(__GI___clone)[0x7f5f8c929293]
       
      Query (0x62b0000a1340): SELECT 1 FROM t1 ORDER BY AVG(pk) OVER (),  SUM( @A := 1 ) OVER ( )
      
      

      /10.5/sql/item_sum.cc:2578: virtual longlong Item_sum_bit::val_int(): Assertion `fixed == 1' failed.
      /10.5/sql/item_sum.cc:2060: virtual my_decimal* Item_sum_avg::val_decimal(my_decimal*): Assertion `fixed == 1' failed.
      /10.5/sql/item_func.cc:3065: virtual longlong Item_func_octet_length::val_int(): Assertion `fixed == 1' failed.

      2.nd execution of such prepared statement crashes the non-debug build:

      210303 12:47:27 [ERROR] mysqld got signal 11 ;
       
      Server version: 10.5.9-MariaDB
       
      sigaction.c:0(__restore_rt)[0x7fd146e453c0]
      sql/item.cc:6653(Item::save_int_in_field(Field*, bool))[0x56383cfe60c5]
      sql/item.cc:6666(Item::save_in_field(Field*, bool))[0x56383cfd7326]
      sql/sql_list.h:441(base_list_iterator::next_fast())[0x56383cf27f52]
      sql/sql_list.h:441(base_list_iterator::next_fast())[0x56383cf29fc9]
      sql/sql_window.cc:3006(Window_funcs_sort::exec(JOIN*, bool))[0x56383cf2a0fe]
      sql/sql_window.cc:3131(Window_funcs_computation::exec(JOIN*, bool))[0x56383cf2a17a]
      sql/sql_select.cc:28963(AGGR_OP::end_send())[0x56383ce00a8c]
      sql/sql_select.cc:20399(sub_select_postjoin_aggr(JOIN*, st_join_table*, bool))[0x56383ce00c61]
      sql/sql_select.cc:20224(JOIN::exec_inner())[0x56383ce1c74a]
      sql/sql_select.cc:4247(JOIN::exec())[0x56383ce1cab3]
      sql/sql_select.cc:4721(mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*))[0x56383ce1ac9e]
      sql/sql_select.cc:429(handle_select(THD*, LEX*, select_result*, unsigned long))[0x56383ce1b7da]
      sql/sql_parse.cc:6283(execute_sqlcom_select(THD*, TABLE_LIST*))[0x56383cc7fb65]
      sql/sql_parse.cc:3978(mysql_execute_command(THD*))[0x56383cdc00c4]
      sql/sql_prepare.cc:5007(Prepared_statement::execute(String*, bool))[0x56383cdd832c]
      sql/sql_prepare.cc:4470(Prepared_statement::execute_loop(String*, bool, unsigned char*, unsigned char*))[0x56383cdd8412]
      sql/sql_class.h:1474(Item_change_list_savepoint::rollback(Item_change_list*))[0x56383cdd86d6]
      sql/sql_parse.cc:3994(mysql_execute_command(THD*))[0x56383cdbebc4]
      sql/sql_parse.cc:8063(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x56383cdc3169]
      sql/sql_audit.h:169(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x56383cdc5215]
      sql/sql_parse.cc:1375(do_command(THD*))[0x56383cdc6bdb]
      sql/sql_connect.cc:1410(do_handle_one_connection(CONNECT*, bool))[0x56383ceb1bc2]
      sql/sql_connect.cc:1318(handle_one_connection)[0x56383ceb1e84]
      perfschema/pfs.cc:2204(pfs_spawn_thread)[0x56383d23528d]
      nptl/pthread_create.c:478(start_thread)[0x7fd146e39609]
      x86_64/clone.S:97(__GI___clone)[0x7fd1469dd293]
       
      Query (0x7fd0e4088cc0): SELECT 1 FROM t1 ORDER BY MIN(pk) OVER (), BIT_XOR(1) OVER ()
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              psergei Sergei Petrunia
              Reporter:
              alice Alice Sherepa
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:

                  Git Integration