1. 25 Jun, 2023 6 commits
    • Michael Widenius's avatar
      MDEV-23106 Unable to recognize/import partitioned tables from physical MySQL databases · 3c7fd3c8
      Michael Widenius authored
      MDEV-29253 Detect incompatible MySQL partition scheme and either convert
      them or report to user and in error log.
      
      This task is about converting in place MySQL 5.6 and 5.7 partition tables
      to MariaDB as part of mariadb-upgrade.
      
      - Update TABLE_SHARE::init_from_binary_frm_image() to be able to read
        MySQL frm files with partitions.
      - Create .par file, if it do not exists, on open of partitioned table.
      
      Executing mariadb-upgrade will create all the missing .par files.
      The MySQL .frm file will be changed to MariaDB format after next
      ALTER TABLE.
      
      Other changes:
      - If we are using stored mysql_version to distingush between MySQL and
        MariaDB  .frm file information, do not upgrade mysql_version in the
        .frm file as part of CHECK TABLE .. FOR UPGRADE as this would cause
        problems next time we parse the .frm file.
      3c7fd3c8
    • Monty's avatar
      Fixed some errors & warnings when running mariadb-upgrade on MySQL instance · d671fec4
      Monty authored
      - Moved view checks after privilege tables are fixed. This is to avoid
        warnings about wrongly defined mysql.proc when checking views.
      - Don't use stat tables before they have been fixed.
      - Don't run mysql_fix_view() if 'FOR MYSQL' is used if the view is
        already a MariaDB view.
      - Added 'FOR UPGRADE' as an option for 'REPAIR VIEW' to be able to
        detect if the REPAIR command comes from mariadb_upgrade. In this
        case we get a warning, instead of an error, if a definer of a view
        does not exists.
      d671fec4
    • Vicentiu Ciorbaru's avatar
      Fix segfault in find_files if db is NULL and path does not exist or can't be read · 324d8a60
      Vicentiu Ciorbaru authored
      In this case, one would end up calling my_error(ER_BAD_DB_ERROR, ...)
      with a null ptr for DB, which caused a NULL ptr dereference.
      324d8a60
    • Vicentiu Ciorbaru's avatar
      Fix gcc warning for wsrep_plug · 38fe266e
      Vicentiu Ciorbaru authored
      38fe266e
    • Vicentiu Ciorbaru's avatar
      Fix use of uninitialized variable · f20d556f
      Vicentiu Ciorbaru authored
      The original code generated a warning in gcc 13.1
      f20d556f
    • Monty's avatar
      Renamed 'mysql' -> 'mariadb' in mtr · ecd8a522
      Monty authored
      ecd8a522
  2. 21 Jun, 2023 1 commit
    • Brandon Nesterenko's avatar
      MDEV-29894: Calling a function from a different database in a slave side trigger crashes · c2d44ecb
      Brandon Nesterenko authored
      When opening and locking tables, if triggers will be invoked in a
      separate database, thd->set_db() is invoked, thus freeeing the memory
      and headers which thd->db had previously pointed to. In row based
      replication, the event execution logic initializes thd->db to point
      to the database which the event targets, which is owned by the
      corresponding table share (introduced in d9898c9a for MDEV-7409).
      The problem then, is that during the table opening and locking
      process for a row event, memory which belongs to the table share
      would be freed, which is not valid.
      
      This patch replaces the thd->reset_db() calls to thd->set_db(),
      which copies-by-value, rather than by reference. Then when the
      memory is freed, our copy of memory is freed, rather than memory
      which belongs to a table share.
      
      Notes:
        1. The call to change thd->db now happens on a higher-level, in
      Rows_log_event::do_apply_event() rather than ::do_exec_row(), in the
      call stack. This is because do_exec_row() is called within a loop,
      and each invocation would redundantly set and unset the db to the
      same value.
        2. thd->set_db() is only used if triggers are to be invoked, as
      there is no vulnerability in the non-trigger case, and copying
      memory would be an unnecessary inefficiency.
      
      Reviewed By:
      ============
      Andrei Elkin <andrei.elkin@mariadb.com>
      c2d44ecb
  3. 09 Jun, 2023 1 commit
    • Tuukka Pasanen's avatar
      MDEV-31423: Make sure that datadir is available with SySV-init script · 8171f9da
      Tuukka Pasanen authored
      Commit fixes Debian SySV-init script fail:
        /etc/init.d/mariadb: line 90: [: : integer expression expected
      which happens if datadir is not changed in configuration which
      makes it invisible when printing MariaDB config defaults.
      
      Commit makes sure that there is some value if nothing else if in hand
      use default /usr/lib/mysql or fail with correct error message if
      directory is not present
      8171f9da
  4. 08 Jun, 2023 7 commits
  5. 07 Jun, 2023 5 commits
  6. 05 Jun, 2023 4 commits
  7. 03 Jun, 2023 15 commits
    • Otto Kekalainen's avatar
      Deb: Fix blocksize check to use $mysql_datadir/$datadir correctly · fcfd6361
      Otto Kekalainen authored
      In commit f99a8918 this line was changed to not use awk, and new version
      copied both to init file and preinst file but overlooking that they use
      different variable names.
      
      Also fix minor syntax issues to make Shellcheck happy.
      
      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.
      fcfd6361
    • Marko Mäkelä's avatar
      MDEV-31350: Hang in innodb.recovery_memory · cf37e44e
      Marko Mäkelä authored
      buf_flush_page_cleaner(): Whenever buf_pool.ran_out(), invoke
      buf_pool.get_oldest_modification(0) so that all clean blocks
      will be removed from buf_pool.flush_list and buf_flush_LRU_list_batch()
      will be able to evict some pages.
      
      This fixes a regression that was likely caused by
      commit a55b951e (MDEV-26827).
      cf37e44e
    • Marko Mäkelä's avatar
      MDEV-31309 Innodb_buffer_pool_read_requests is not updated correctly · dd298873
      Marko Mäkelä authored
      srv_export_innodb_status(): Update
      export_vars.innodb_buffer_pool_read_requests as it was done
      before commit a55b951e (MDEV-26827).
      If innodb_status_variables[] pointed to a sharded variable, it would
      only access the first shard.
      dd298873
    • Marko Mäkelä's avatar
      MDEV-31308 InnoDB monitor trx_rseg_history_len was accidentally disabled by default · 89eb6fa8
      Marko Mäkelä authored
      innodb_counter_info[]: Revert a change that was accidentally made in
      commit 204e7225
      89eb6fa8
    • Marko Mäkelä's avatar
      MDEV-31158: Potential hang with ROW_FORMAT=COMPRESSED tables · 883333a7
      Marko Mäkelä authored
      btr_cur_need_opposite_intention(): Check also page_zip_available()
      so that we will escalate to exclusive index latch when a non-leaf
      page may have to be split further due to ROW_FORMAT=COMPRESSED page
      overflow.
      
      Tested by: Matthias Leich
      883333a7
    • Marko Mäkelä's avatar
      MDEV-29593 fixup: Avoid a leak if rseg.undo_cached is corrupted · 459eb9a6
      Marko Mäkelä authored
      trx_purge_truncate_rseg_history(): Avoid a leak similar to the one
      that was fixed in MDEV-31324, in case a supposedly cached undo log
      page is not found in the rseg.undo_cached list.
      459eb9a6
    • Marko Mäkelä's avatar
      MDEV-31343 Another server hang with innodb_undo_log_truncate=ON · e89bd39c
      Marko Mäkelä authored
      trx_purge_truncate_history(): While waiting for a write-fixed block
      to become available, simply wait for an exclusive latch on it.
      Also, simplify the iteration: first check for oldest_modification>2
      (to ignore clean pages or pages belonging to the temporary tablespace)
      and then compare the tablespace identifier.
      
      Before releasing buf_pool.flush_list_mutex we will buffer-fix the block
      of interest. In that way, buf_page_t::can_relocate() will not hold on
      the block and it must remain in the buffer pool until we have acquired
      an exclusive latch on it. If the block is still dirty, we will register
      it with the tablespace truncation mini-transaction; else, we will simply
      release the latch and buffer-fix and move to the next block.
      
      This also reverts commit c4d79399
      because that fix should no longer be necessary; the wait for an
      exclusive block latch should allow buf_pool_t::release_freed_page()
      on the same block to proceed.
      
      Tested by: Axel Schwenke, Matthias Leich
      e89bd39c
    • 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
  8. 02 Jun, 2023 1 commit