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

set global system_versioning_asof=sf() crashes in specific case

    XMLWordPrintable

Details

    Description

      If global variable is addressed inside a stored function, set global system_versioning_asof causes crash:

      create or replace function NOW_GLOBAL() returns timestamp
        return  CONVERT_TZ(now(), @@session.time_zone, @@global.time_zone);
      set global system_versioning_asof= NOW_GLOBAL();
      

      safe_mutex: Trying to lock mutex at ../sql/item_func.cc, line 5668, when the mutex was already locked at ../sql/sys_vars_shared.h, line 55 in thread T@6
       
      Thread pointer: 0x7f03f0000cf8
      stack_bottom = 0x7f0406fc2dc8 thread_stack 0x49000
      /home/foo/src/mariadb/bld/sql/mysqld(my_print_stacktrace+0x4f)[0x558095acc464]
      mysys/stacktrace.c:269(my_print_stacktrace)[0x5580952d22c4]
      sigaction.c:0(__restore_rt)[0x7f041408fb90]
      :0(__GI_raise)[0x7f0411580efb]
      :0(__GI_abort)[0x7f04115822c1]
      /home/foo/src/mariadb/bld/sql/mysqld(safe_mutex_lock+0x149)[0x558095ad15dd]
      mysys/thr_mutex.c:268(safe_mutex_lock)[0x558095353384]
      psi/mysql_thread.h:695(inline_mysql_mutex_lock)[0x558095368008]
      sql/item_func.cc:5669(Item_func_get_system_var::fix_length_and_dec())[0x55809535495a]
      sql/item_func.cc:381(Item_func::fix_fields(THD*, Item**))[0x55809535478d]
      sql/item_func.cc:363(Item_func::fix_fields(THD*, Item**))[0x558094ef7490]
      sql/sp_head.cc:375(THD::sp_fix_func_item(Item**))[0x558094ef737b]
      sql/sp_head.cc:362(THD::sp_prepare_func_item(Item**, unsigned int))[0x558095298603]
      sql/field.cc:1330(Field::sp_prepare_and_store_item(THD*, Item**))[0x558094ef769e]
      sql/sp_head.cc:411(THD::sp_eval_expr(Field*, Item**))[0x558094f0fbdb]
      sql/sp_rcontext.cc:424(sp_rcontext::set_return_value(THD*, Item**))[0x558094f021c5]
      sql/sp_head.cc:4014(sp_instr_freturn::exec_core(THD*, unsigned int*))[0x558094f00240]
      sql/sp_head.cc:3317(sp_lex_keeper::reset_lex_and_exec_core(THD*, unsigned int*, bool, sp_instr*))[0x558094f020fa]
      sql/sp_head.cc:3971(sp_instr_freturn::execute(THD*, unsigned int*))[0x558094efa4a4]
      sql/sp_head.cc:1354(sp_head::execute(THD*, bool))[0x558094efc038]
      sql/sp_head.cc:2011(sp_head::execute_function(THD*, Item**, unsigned int, Field*, sp_rcontext**, Query_arena*))[0x5580952f4912]
      sql/item.cc:2956(Item_sp::execute_impl(THD*, Item**, unsigned int))[0x5580952f44ed]
      sql/item.cc:2871(Item_sp::execute(THD*, bool*, Item**, unsigned int))[0x55809536a907]
      sql/item_func.cc:6387(Item_func_sp::execute())[0x558095370c42]
      sql/item_func.h:2873(Item_func_sp::get_date(st_mysql_time*, unsigned long long))[0x558095172f38]
      sql/sys_vars.ic:2647(Sys_var_vers_asof::update(set_var*, vers_asof_timestamp_t&, system_variables&))[0x55809517301e]
      sql/sys_vars.ic:2665(Sys_var_vers_asof::global_update(THD*, set_var*))[0x558094ed71aa]
      sql/set_var.cc:208(sys_var::update(THD*, set_var*))[0x558094ed9088]
      sql/set_var.cc:827(set_var::update(THD*))[0x558094ed8c53]
      sql/set_var.cc:728(sql_set_variables(THD*, List<set_var_base>*, bool))[0x558094fdcfaa]
      sql/sql_parse.cc:5136(mysql_execute_command(THD*))[0x558094fe6543]
      sql/sql_parse.cc:8019(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x558094fd3443]
      sql/sql_parse.cc:1848(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x558094fd1e4a]
      sql/sql_parse.cc:1390(do_command(THD*))[0x55809513fd8e]
      sql/sql_connect.cc:1402(do_handle_one_connection(CONNECT*))[0x55809513faf6]
      sql/sql_connect.cc:1309(handle_one_connection)[0x558095a61508]
      pthread_create.c:0(start_thread)[0x7f04140850bc]
      :0(__GI___clone)[0x7f04116432ff]
      

      This happenns because we access value->get_date() from update(), which locks global variables, because I used one in stored function, so we get double lock.

      Attachments

        Issue Links

          Activity

            People

              nikitamalyavin Nikita Malyavin
              nikitamalyavin Nikita Malyavin
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.