1. 06 Jul, 2023 1 commit
  2. 05 Jul, 2023 1 commit
  3. 03 Jul, 2023 1 commit
  4. 29 Jun, 2023 2 commits
    • Alexander Barkov's avatar
      MDEV-31578 DECLARE CURSOR: "Memory not freed: 280 bytes lost" on syntax error · fdab2c4c
      Alexander Barkov authored
      When CURSOR parameters get parsed, their sp_assignment_lex instances
      (one instance per parameter) get collected to List<sp_assignment_lex>.
      
      These instances get linked to sphead only in the end of the list.
      If a syntax error happened in the middle of the parameter list,
      these instances were not deleted, which caused memory leaks.
      
      Fix:
      
      using a Bison %destructor to free rules of the <sp_assignment_lex_list>
      type (on syntax errors).
      
      Afte the fix these sp_assignment_lex instances from CURSOR parameters
      deleted as follows:
      
      - If the CURSOR statement was fully parsed, then these instances
        get properly linked to sp_head structures, so they are deleted
        during ~sp_head (this did not change)
      
      - If the CURSOR statement failed on a syntax error, then by Bison's
        %destructor (this is being added in the current patch).
      fdab2c4c
    • Alexander Barkov's avatar
      MDEV-30680 Warning: Memory not freed: 280 on mangled query, LeakSanitizer: detected memory leaks · 0d3720c1
      Alexander Barkov authored
      The parser works as follows:
      
      The rule expr_lex returns a pointer to a newly created sp_expr_lex
      instance which is not linked to any MariaDB structures yet - it is
      pointed only from a Bison stack variable. The sp_expr_lex instance
      gets linked to other structures (such as sp_instr_jump_if_not) later,
      after scanning some following grammar.
      
      Problem before the fix:
      If a parse error happened immediately after expr_lex (before it got linked),
      the created sp_expr_lex value got lost causing a memory leak.
      
      Fix:
      
      - Using Bison's "destructor" directive to free the results of expr_lex
        on parse/oom errors.
      
      - Moving the call for LEX::cleanup_lex_after_parse_error() from
        MYSQL_YYABORT and yyerror inside parse_sql().
        This is needed because Bison calls destructors after yyerror(),
        while it's important to delete the sp_expr_lex instance before
        LEX::cleanup_lex_after_parse_error().
        The latter frees the memory root containing the sp_expr_lex instance.
      
        After this change the code block are executed in the following order:
      
        - yyerror() -- now only raises the error to DA (no cleanup done any more)
        - %destructor { delete $$; } <expr_lex>  -- destructs the sp_expr_lex instance
        - LEX::cleanup_lex_after_parse_error()   -- frees the memory root containing
                                                    the sp_expr_lex instance
      
      - Removing the "delete sublex" related code from restore_lex():
        - restore_lex() is called in most cases on success, when delete is not needed.
        - There is one place when restore_lex() is called on error:
          In sp_create_assignment_instr(). But in this case LEX::sp_lex_in_use
          is true anyway.
          The patch adds a new DBUG_ASSERT(lex->sp_lex_in_use) to guard this.
      0d3720c1
  5. 28 Jun, 2023 2 commits
  6. 27 Jun, 2023 1 commit
  7. 20 Jun, 2023 1 commit
  8. 16 Jun, 2023 1 commit
  9. 15 Jun, 2023 1 commit
  10. 14 Jun, 2023 1 commit
    • Sergei Petrunia's avatar
      MDEV-31479: Inconsistency between MRR and SQL layer costs can cause poor query plan · 0e2e70c4
      Sergei Petrunia authored
      (Same as
      TODO-3938: best_access_path shows negative costs for mrr=on)
      
      best_access_path() assumes that quick select cost includes
      (quick->rows/TIME_FOR_COMPARE) as a cost of checking the attached
      part of the WHERE condition.
      
      It calls adjust_quick_cost() to subtract addition from quick's cost.
      
      The problem was that DS-MRR cost formula didn't include this cost.
      For very large tables, adjust_quick_cost() would produce a negative
      cost which would cause assert in debug build or bad query plan choice
      in release builds.
      Approved-by: default avatarMonty <monty@mariadb.org>
      0e2e70c4
  11. 09 Jun, 2023 1 commit
    • Thirunarayanan Balathandayuthapani's avatar
      MDEV-31442 page_cleaner thread aborts while releasing the tablespace · 841e905f
      Thirunarayanan Balathandayuthapani authored
      After further I/O on a tablespace has been stopped
      (for example due to DROP TABLE or an operation that
      rebuilds a table), page cleaner thread tries to
      flush the pending writes for the tablespace and
      releases the tablespace reference even though it was not
      acquired.
      
      fil_space_t::flush(): Don't release the tablespace when it is
      being stopped and closed
      
      Thanks to Marko Mäkelä for suggesting this patch.
      841e905f
  12. 08 Jun, 2023 5 commits
  13. 07 Jun, 2023 3 commits
  14. 05 Jun, 2023 2 commits
  15. 03 Jun, 2023 8 commits
    • Marko Mäkelä's avatar
      MDEV-31234 fixup: Allow innodb_undo_log_truncate=ON after upgrade · 3b4b512d
      Marko Mäkelä authored
      trx_purge_truncate_history(): Relax a condition that would prevent
      undo log truncation if the undo log tablespaces were "contaminated"
      by the bug that commit e0084b9d fixed.
      That is, trx_purge_truncate_rseg_history() would have invoked
      flst_remove() on TRX_RSEG_HISTORY but not reduced TRX_RSEG_HISTORY_SIZE.
      
      To avoid any regression with normal operation, we implement this
      fixup during slow shutdown only. The condition on the history list
      being empty is necessary: without it, in the test
      innodb.undo_truncate_recover there may be much fewer than the
      expected 90,000 calls to row_purge() before the truncation.
      That is, we would truncate the undo tablespace before actually having
      processed all undo log records in it.
      
      To truncate such "contaminated" or "bloated" undo log tablespaces
      (when using innodb_undo_tablespaces=2 or more)
      you can execute the following SQL:
      
      BEGIN;INSERT mysql.innodb_table_stats VALUES('','',DEFAULT,0,0,0);ROLLBACK;
      SET GLOBAL innodb_undo_log_truncate=ON, innodb_fast_shutdown=0;
      SHUTDOWN;
      
      The first line creates a dummy InnoDB transaction, to ensure that there
      will be some history to be purged during shutdown and that the undo
      tablespaces will be truncated.
      3b4b512d
    • Marko Mäkelä's avatar
      MDEV-31234 fixup: Free some UNDO pages earlier · 48d6a5f6
      Marko Mäkelä authored
      trx_purge_truncate_rseg_history(): Add a parameter to specify if
      the entire rollback segment is safe to be freed. If not, we may
      still be able to invoke trx_undo_truncate_start() and free some pages.
      48d6a5f6
    • Marko Mäkelä's avatar
      MDEV-31234 InnoDB does not free UNDO after the fix of MDEV-30671 · 318012a8
      Marko Mäkelä authored
      trx_purge_truncate_history(): Only call trx_purge_truncate_rseg_history()
      if the rollback segment is safe to process. This will avoid leaking undo
      log pages that are not yet ready to be processed. This fixes a regression
      that was introduced in
      commit 0de3be8c (MDEV-30671).
      
      trx_sys_t::any_active_transactions(): Separately count XA PREPARE
      transactions.
      
      srv_purge_should_exit(): Terminate slow shutdown if the history size
      does not change and XA PREPARE transactions exist in the system.
      This will avoid a hang of the test innodb.recovery_shutdown.
      
      Tested by: Matthias Leich
      318012a8
    • Sergei Golubchik's avatar
      eb472f77
    • Sergei Golubchik's avatar
      Revert "MDEV-30473 : Do not allow GET_LOCK() / RELEASE_LOCK() in cluster" · 0fd54c98
      Sergei Golubchik authored
      This reverts commit 844ddb11.
      
      This fixes MDEV-30967, MDEV-31325, MDEV-31388
      0fd54c98
    • Igor Babaev's avatar
      MDEV-31240 Crash with condition pushable into derived and containing outer reference · 8f3bf593
      Igor Babaev authored
      This bug could affect queries containing a subquery over splittable derived
      tables and having an outer references in its WHERE clause. If such subquery
      contained an equality condition whose left part was a reference to a column
      of the derived table and the right part referred only to outer columns
      then the server crashed in the function st_join_table::choose_best_splitting()
      The crashing code was added in the commit ce7ffe61
      that made the code of the function sensitive to presence of the flag
      OUTER_REF_TABLE_BIT in the KEYUSE_EXT::needed_in_prefix fields.
      
      The field needed_in_prefix of the KEYUSE_EXT structure should not contain
      table maps with OUTER_REF_TABLE_BIT or RAND_TABLE_BIT.
      
      Note that this fix is quite conservative: for affected queries it just
      returns the query plans that were used before the above mentioned commit.
      In fact the equalities causing crashes should be pushed into derived tables
      without any usage of split optimization.
      
      Approved by Sergei Petrunia <sergey@mariadb.com>
      8f3bf593
    • Igor Babaev's avatar
      MDEV-31224 Crash with EXPLAIN EXTENDED for multi-table update of system table · aa713f5a
      Igor Babaev authored
      EXPLAIN EXTENDED should always print the field item used in the left part
      of an equality expression from the SET clause of an update statement as a
      reference to table column.
      
      Approved by Oleksandr Byelkin <sanja@mariadb.com>
      aa713f5a
    • Daniel Bartholomew's avatar
      bump the VERSION · 54324e54
      Daniel Bartholomew authored
      54324e54
  16. 01 Jun, 2023 2 commits
  17. 24 May, 2023 2 commits
  18. 23 May, 2023 5 commits
    • Marko Mäkelä's avatar
      MDEV-31234 fixup: Allow innodb_undo_log_truncate=ON after upgrade · 9c35f9c9
      Marko Mäkelä authored
      trx_purge_truncate_history(): Relax a condition that would prevent
      undo log truncation if the undo log tablespaces were "contaminated"
      by the bug that commit e0084b9d fixed.
      That is, trx_purge_truncate_rseg_history() would have invoked
      flst_remove() on TRX_RSEG_HISTORY but not reduced TRX_RSEG_HISTORY_SIZE.
      
      To avoid any regression with normal operation, we implement this
      fixup during slow shutdown only. The condition on the history list
      being empty is necessary: without it, in the test
      innodb.undo_truncate_recover there may be much fewer than the
      expected 90,000 calls to row_purge() before the truncation.
      That is, we would truncate the undo tablespace before actually having
      processed all undo log records in it.
      
      To truncate such "contaminated" or "bloated" undo log tablespaces
      (when using innodb_undo_tablespaces=2 or more)
      you can execute the following SQL:
      
      BEGIN;INSERT mysql.innodb_table_stats VALUES('','',DEFAULT,0,0,0);ROLLBACK;
      SET GLOBAL innodb_undo_log_truncate=ON, innodb_fast_shutdown=0;
      SHUTDOWN;
      
      The first line creates a dummy InnoDB transaction, to ensure that there
      will be some history to be purged during shutdown and that the undo
      tablespaces will be truncated.
      9c35f9c9
    • Monty's avatar
      Optimized version of safe_strcpy() · a7adfd4c
      Monty authored
      Note: We should replace most case of safe_strcpy() with strmake() to avoid
      the not needed zerofill.
      a7adfd4c
    • Monty's avatar
      MDEV-28285 Unexpected result when combining DISTINCT, subselect and LIMIT · 92d2ceac
      Monty authored
      The problem was that when  JOIN_TAB::remove_duplicates() noticed there
      can only be one possible row in the output, it adjusted limits but
      didn't take into account any possible offset.
      
      Fixed by not adjusting limit offset when setting one-row-limit.
      92d2ceac
    • Monty's avatar
      MDEV-31083 ASAN use-after-poison in myrg_attach_children · cd37e494
      Monty authored
      The reason for ASAN report was that the MERGE and MYISAM file
      had different key definitions, which is not allowed.
      
      Fixed by ensuring that the MERGE code is not copying more key stats
      than what is in the MyISAM file.
      
      Other things:
      - Give an error if different MyISAM files has different number of
        key parts.
      cd37e494
    • Monty's avatar
      Update main.selectivity test and results · c7e04af8
      Monty authored
      c7e04af8