1. 28 Jun, 2023 1 commit
  2. 27 Jun, 2023 1 commit
  3. 20 Jun, 2023 1 commit
  4. 16 Jun, 2023 1 commit
  5. 15 Jun, 2023 1 commit
  6. 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
  7. 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
  8. 08 Jun, 2023 5 commits
  9. 07 Jun, 2023 3 commits
  10. 05 Jun, 2023 2 commits
  11. 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
  12. 01 Jun, 2023 2 commits
  13. 24 May, 2023 2 commits
  14. 23 May, 2023 6 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
    • Monty's avatar
      Make install.db read only in mtr · 6a031406
      Monty authored
      This ensures that no mtr test can change install.db after it's initial
      creation as changing it while as another thread is coping it will lead to
      failures in at least InnoDB and Aria recovery.
      
      Fixed spider/bugfix.mdev_30370 that was wrongly used install.db
      6a031406
  15. 22 May, 2023 2 commits
    • Monty's avatar
      MDEV-6768 Wrong result with aggregate with join with no result set · 16258677
      Monty authored
      When a query does implicit grouping and join operation produces an empty
      result set, a NULL-complemented row combination is generated.
      However, constant table fields still show non-NULL values.
      
      What happens in the is that end_send_group() is called with a
      const row but without any rows matching the WHERE clause.
      This last part is shown by 'join->first_record' not being set.
      
      This causes item->no_rows_in_result() to be called for all items to reset
      all sum functions to their initial state. However fields are not set
      to NULL.
      
      The used fix is to produce NULL-complemented records for constant tables
      as well. Also, reset the constant table's records back in case we're
      in a subquery which may get re-executed.
      An alternative fix would have item->no_rows_in_result() also work
      with Item_field objects.
      
      There is some other issues with the code:
      - join->no_rows_in_result_called is used but never set.
      - Tables that are used with group functions are not properly marked as
        maybe_null, which is required if the table rows should be regarded as
        null-complemented (not existing).
      - The code that tries to detect if mixed_implicit_grouping should be set
        didn't take into account all usage of fields and sum functions.
      - Item_func::restore_to_before_no_rows_in_result() called the wrong
        function.
      - join->clear() does not use a table_map argument to clear_tables(),
        which caused it to ignore constant tables.
      - unclear_tables() does not correctly restore status to what is
        was before clear_tables().
      
      Main bug fix was to always use a table_map argument to clear_tables() and
      always use join->clear() and clear_tables() together with unclear_tables().
      
      Other fixes:
      - Fixed Item_func::restore_to_before_no_rows_in_result()
      - Set 'join->no_rows_in_result_called' when no_rows_in_result_set()
        is called.
      - Removed not used argument from setup_end_select_func().
      - More code comments
      - Ensure that end_send_group() modifies the same fields as are in the
        result set.
      - Changed return_zero_rows() to use pointers instead of references,
        similar to the rest of the code.
      
      Reviewer: Sergei Petrunia <sergey@mariadb.com>
      16258677
    • Daniel Black's avatar
      MDEV-31268: Fedora mariadb-connector-c-config conflicts with MariaDB's MariaDB-common · c0adb05b
      Daniel Black authored
      The previous fix in MDEV-24629 had a version end of life date.
      
      Thanks @pgnd on Zulip for noticing.
      c0adb05b
  16. 21 May, 2023 1 commit
    • Teemu Ollakka's avatar
      MDEV-29293 MariaDB stuck on starting commit state · 3f59bbee
      Teemu Ollakka authored
      The problem seems to be a deadlock between KILL command execution
      and BF abort issued by an applier, where:
      * KILL has locked victim's LOCK_thd_kill and LOCK_thd_data.
      * Applier has innodb side global lock mutex and victim trx mutex.
      * KILL is calling innobase_kill_query, and is blocked by innodb
        global lock mutex.
      * Applier is in wsrep_innobase_kill_one_trx and is blocked by
        victim's LOCK_thd_kill.
      
      The fix in this commit removes the TOI replication of KILL command
      and makes KILL execution less intrusive operation. Aborting the
      victim happens now by using awake_no_mutex() and ha_abort_transaction().
      If the KILL happens when the transaction is committing, the
      KILL operation is postponed to happen after the statement
      has completed in order to avoid KILL to interrupt commit
      processing.
      
      Notable changes in this commit:
      * wsrep client connections's error state may remain sticky after
        client connection is closed. This error message will then pop
        up for the next client session issuing first SQL statement.
        This problem raised with test galera.galera_bf_kill.
        The fix is to reset wsrep client error state, before a THD is
        reused for next connetion.
      * Release THD locks in wsrep_abort_transaction when locking
        innodb mutexes. This guarantees same locking order as with applier
        BF aborting.
      * BF abort from MDL was changed to do BF abort on server/wsrep-lib
        side first, and only then do the BF abort on InnoDB side. This
        removes the need to call back from InnoDB for BF aborts which originate
        from MDL and simplifies the locking.
      * Removed wsrep_thd_set_wsrep_aborter() from service_wsrep.h.
        The manipulation of the wsrep_aborter can be done solely on
        server side. Moreover, it is now debug only variable and
        could be excluded from optimized builds.
      * Remove LOCK_thd_kill from wsrep_thd_LOCK/UNLOCK to allow more
        fine grained locking for SR BF abort which may require locking
        of victim LOCK_thd_kill. Added explicit call for
        wsrep_thd_kill_LOCK/UNLOCK where appropriate.
      * Wsrep-lib was updated to version which allows external
        locking for BF abort calls.
      
      Changes to MTR tests:
      * Disable galera_bf_abort_group_commit. This test is going to
        be removed (MDEV-30855).
      * Record galera_gcache_recover_manytrx as result file was incomplete.
        Trivial change.
      * Make galera_create_table_as_select more deterministic:
        Wait until CTAS execution has reached MDL wait for multi-master
        conflict case. Expected error from multi-master conflict is
        ER_QUERY_INTERRUPTED. This is because CTAS does not yet have open
        wsrep transaction when it is waiting for MDL, query gets interrupted
        instead of BF aborted. This should be addressed in separate task.
      * A new test galera_kill_group_commit to verify correct behavior
        when KILL is executed while the transaction is committing.
      Co-authored-by: default avatarSeppo Jaakola <seppo.jaakola@iki.fi>
      Co-authored-by: default avatarJan Lindström <jan.lindstrom@galeracluster.com>
      Signed-off-by: default avatarJulius Goryavsky <julius.goryavsky@mariadb.com>
      3f59bbee
  17. 19 May, 2023 2 commits
    • Robin Newhouse's avatar
      Backport GitLab CI to 10.5 · 03d4fd32
      Robin Newhouse authored
      Add .gitlab-ci.yml file to earliest supported branch to enable
      automated building and testing for all MariaDB major branches.
      
      Note to mergers:
      GitLab CI is available for branches >= 10.6. This commit includes a
      GitLab CI file identical to that in branches >= 10.6, except for the
      MARIADB_MAJOR_VERSION variable which should reflect the branch version.
      A modified CI will be included in branches 10.4 with PR !2418.
      Also changed is the `allow_failure: true` for the MSAN build,
      which should be merged up to later branches.
      
      All new code of the whole pull request, including one or several files
      that are either new files or modified ones, are contributed under the
      BSD-new license. I am contributing on behalf of my employer
      Amazon Web Services, Inc.
      03d4fd32
    • Vlad Lesin's avatar
      MDEV-31256 fil_node_open_file() releases fil_system.mutex allowing other... · 54227847
      Vlad Lesin authored
      MDEV-31256 fil_node_open_file() releases fil_system.mutex allowing other thread to open its file node
      
      There is room between mutex_exit(&fil_system.mutex) and
      mutex_enter(&fil_system.mutex) calls in fil_node_open_file(). During this
      room another thread can open the node, and ut_ad(!node->is_open())
      assertion in fil_node_open_file_low() can fail.
      
      The fix is not to open node if it was already opened by another thread.
      54227847