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

Crash using versioning plugin functions after plugin was removed from server

    XMLWordPrintable

Details

    Description

      Reproduce

      install plugin test_versioning soname 'test_versioning.so';
      uninstall plugin test_versioning;
      --error ER_SP_DOES_NOT_EXIST
      select trt_begin_ts(0);
      

      Result

      Server crash.

      Possible fix (10.5 or later only)

      Wrap SQL functions defined in plugin/versioning/versioning.cc into MariaDB_FUNCTION_PLUGIN

      The plugin implemented in plugin/versioning/versioning.cc defines a number of SQL functions:

      static Native_func_registry func_array[] =
      {
        { { C_STRING_WITH_LEN("TRT_BEGIN_TS") }, BUILDER(Create_func_trt<TR_table::FLD_BEGIN_TS>)},
        { { C_STRING_WITH_LEN("TRT_COMMIT_ID") }, BUILDER(Create_func_trt<TR_table::FLD_COMMIT_ID>)},
        { { C_STRING_WITH_LEN("TRT_COMMIT_TS") }, BUILDER(Create_func_trt<TR_table::FLD_COMMIT_TS>)},
        { { C_STRING_WITH_LEN("TRT_ISO_LEVEL") }, BUILDER(Create_func_trt<TR_table::FLD_ISO_LEVEL>)},
        { { C_STRING_WITH_LEN("TRT_TRX_ID") }, BUILDER(Create_func_trt<TR_table::FLD_TRX_ID>)},
        { { C_STRING_WITH_LEN("TRT_TRX_SEES") }, BUILDER(Create_func_trt_trx_sees<Item_func_trt_trx_sees>)},
        { { C_STRING_WITH_LEN("TRT_TRX_SEES_EQ") }, BUILDER(Create_func_trt_trx_sees<Item_func_trt_trx_sees_eq>)},
        { {0, 0}, NULL}
      };
      

      At initialization time it adds these SQL functions into the global SQL function hash native_functions_hash by calling item_create_append():

      static int versioning_plugin_init(void *p __attribute__ ((unused)))
      {
        DBUG_ENTER("versioning_plugin_init");
        // No need in locking since we so far single-threaded
        int res= item_create_append(func_array);
        if (res)
        {
          my_message(ER_PLUGIN_IS_NOT_LOADED, "Can't append function array" , MYF(0));
          DBUG_RETURN(res);
        }
       
        DBUG_RETURN(0);
      }
      

      At de-initialization time it does not remove these functions from the global hash native_functions_hash. So if we de-install the plugin and try to use the mentioned SQL functions, the server will crash.

      Under terms of this task we'll turn these SQL functions into MariaDB_FUNCTION_PLUGIN, so they are not added to the global hash native_functions_hash.

      Attachments

        Issue Links

          Activity

            People

              midenok Aleksey Midenkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              6 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.