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

Memory leak of derived_handler when a multi-table UPDATE fails after derived-table prepare statement.

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 13.2
    • 13.2.1
    • Optimizer
    • Either a valgrind or ASAN builds on a linux machine
    • Can result in unexpected behaviour

    Description

      Memory leak of derived_handler when a multi-table UPDATE fails after derived-table prepare statement.

      With a FederatedX table t2 pointing at a remote server, and federated_pushdown=1:

      SET GLOBAL federated_pushdown=1;
      WITH cte1 AS (SELECT * FROM t2 WHERE t2.a < 5)
      UPDATE cte1 SET cte1.a = cte1.a * 2;
      

      Running it again with EXPLAIN in front also leaks, so each statement leaks one handler.

      Both statements are in federated.federatedx_pushdown_upd_del (about lines 145-153). The leak shows up under valgrind.:

      1,296 bytes in 2 blocks are definitely lost
         at operator new(unsigned long)
         by TABLE_LIST::find_derived_handler(THD*)            (sql_derived.cc:1751)
         by mysql_derived_prepare(THD*, LEX*, TABLE_LIST*)    (sql_derived.cc:949)
         by mysql_derived_merge_for_insert(...)               (sql_derived.cc:549)
         by mysql_handle_derived(LEX*, unsigned int)          (sql_derived.cc:158)
         by Multiupdate_prelocking_strategy::handle_end(THD*) (sql_update.cc:1688)
         by open_tables(...)
         by Sql_cmd_dml::prepare(THD*)                        (sql_select.cc:35879)
      

      Note: This issue is found with MDEV-39226 (multi-table UPDATE/DELETE pushdown). But, it is technically independent of that change, since the leak path is in the derived-handler code.

      Attachments

        Issue Links

          Activity

            People

              bsrikanth Srikanth Bondalapati
              bsrikanth Srikanth Bondalapati
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 2d
                  2d
                  Remaining:
                  Remaining Estimate - 0d
                  0d
                  Logged:
                  Time Spent - 1d Time Not Required
                  1d

                  Git Integration

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