1. 08 Feb, 2024 11 commits
    • Marko Mäkelä's avatar
      Merge 10.6 into 10.11 · 86c2c897
      Marko Mäkelä authored
      86c2c897
    • Marko Mäkelä's avatar
      MDEV-33421 innodb.corrupted_during_recovery fails due to error that the table is corrupted · 77b43995
      Marko Mäkelä authored
      This fixes up the merge commit 7e39470e
      
      dict_table_open_on_name(): Report ER_TABLE_CORRUPT in a consistent
      fashion, with a pretty-printed table name.
      77b43995
    • Marko Mäkelä's avatar
      Merge 10.5 into 10.6 · 466069b1
      Marko Mäkelä authored
      466069b1
    • Marko Mäkelä's avatar
      MDEV-33277 In-place upgrade causes invalid AUTO_INCREMENT values · 0381921e
      Marko Mäkelä authored
      MDEV-33308 CHECK TABLE is modifying .frm file even if --read-only
      
      As noted in commit d0ef1aaf,
      MySQL as well as older versions of MariaDB server would during
      ALTER TABLE ... IMPORT TABLESPACE write bogus values to the
      PAGE_MAX_TRX_ID field to pages of the clustered index, instead of
      letting that field remain 0.
      In commit 8777458a this field
      was repurposed for PAGE_ROOT_AUTO_INC in the clustered index root page.
      
      To avoid trouble when upgrading from MySQL or older versions of MariaDB,
      we will try to detect and correct bogus values of PAGE_ROOT_AUTO_INC
      when opening a table for the first time from the SQL layer.
      
      btr_read_autoinc_with_fallback(): Add the parameters to mysql_version,max
      to indicate the TABLE_SHARE::mysql_version of the .frm file and the
      maximum value allowed for the type of the AUTO_INCREMENT column.
      In case the table was originally created in MySQL or an older version of
      MariaDB, read also the maximum value of the AUTO_INCREMENT column from
      the table and reset the PAGE_ROOT_AUTO_INC if it is above the limit.
      
      dict_table_t::get_index(const dict_col_t &) const: Find an index that
      starts with the specified column.
      
      ha_innobase::check_for_upgrade(): Return HA_ADMIN_FAILED if InnoDB
      needs upgrading but is in read-only mode. In this way, the call to
      update_frm_version() will be skipped.
      
      row_import_autoinc(): Adjust the AUTO_INCREMENT column at the end of
      ALTER TABLE...IMPORT TABLESPACE. This refinement was suggested by
      Debarun Banerjee.
      
      The changes outside InnoDB were developed by Michael 'Monty' Widenius:
      
      Added print_check_msg() service for easy reporting of check/repair messages
      in ENGINE=Aria and ENGINE=InnoDB.
      Fixed that CHECK TABLE do not update the .frm file under --read-only.
      Added 'handler_flags' to HA_CHECK_OPT as a way for storage engines to
      store state from handler::check_for_upgrade().
      
      Reviewed by: Debarun Banerjee
      0381921e
    • Daniel Black's avatar
      MDEV-4827 mysqldump --dump-slave=2 --master-data=2 doesn't record both · 915d9514
      Daniel Black authored
      Recording both is useful on a replication relay when the backup
      can be used to replace the server, or ack as a new replica to the
      server.
      
      If an option=2, commented is selected, allow the alternate option
      to exist.
      
      This still disables --dump-slave=1 --master-data=1 as having the
      a CHANGE MASTER TO and START SLAVE on different positions would be
      confusing and dangerious to the try to execute the output. The
      previous behaviour of silently disabling --master-data occurs in
      this case.
      
      The commented code related to --dump-slave/--master-data is greatly
      expanded for human consumption.
      
      A redundant opt_slave_data= 0 was removed from get_opts. If
      --dump-slave=1 or 2, then the only possible value of --master-data
      is a valid one.
      
      Re-order to preference gtid based replication.
      
      Based of code from Elena Stepanova.
      
      Review by: Brandon Nesterenko and Anel Husakovic
      915d9514
    • Daniel Black's avatar
      MDEV-4827: prelude - additional gtid/no-gtid tests for mysqldump · f7adf129
      Daniel Black authored
      This will make it easier to show changes.
      f7adf129
    • Marko Mäkelä's avatar
      MDEV-32899 InnoDB is holding shared dict_sys.latch while waiting for FOREIGN... · b2654ba8
      Marko Mäkelä authored
      MDEV-32899 InnoDB is holding shared dict_sys.latch while waiting for FOREIGN KEY child table lock on DDL
      
      lock_table_children(): A new function to lock all child tables of a table.
      We will only hold dict_sys.latch while traversing
      dict_table_t::referenced_set. To prevent a race condition with
      std::set::erase() we will copy the pointers to the child tables to a
      local vector. Once we have acquired MDL and references to all child tables,
      we can safely release dict_sys.latch, wait for the locks, and finally
      release the references.
      
      dict_acquire_mdl_shared(): A new variant that takes mdl_context as a
      parameter.
      
      lock_table_for_trx(): Assert that we are not holding dict_sys.latch.
      
      ha_innobase::truncate(): When foreign_key_checks=ON, assert that
      no child tables exist (other than the current table).
      In any case, we will invoke lock_table_children()
      so that the child table metadata can be safely updated.
      (It is possible that a child table is being created concurrently
      with TRUNCATE TABLE.)
      
      ha_innobase::delete_table(): Before and after acquiring exclusive
      locks on the current table as well as all child tables,
      check that FOREIGN KEY constraints will not be violated.
      In this way, we can reject impossible DROP TABLE without having to
      wait for locks first.
      
      This fixes up commit 2ca11234 (MDEV-26217)
      and commit c3c53926 (MDEV-26554).
      b2654ba8
    • Marko Mäkelä's avatar
      MDEV-24167 fixup: srw_lock_debug instrumentation · 5f2dcd11
      Marko Mäkelä authored
      While the index_lock and block_lock include debug instrumentation
      to keep track of shared lock holders, such instrumentation was
      never part of the simpler srw_lock, and therefore some users of the
      class implemented a limited form of bookkeeping.
      
      srw_lock_debug encapsulates srw_lock and adds the data members
      writer, readers_lock, and readers to keep track of the threads that
      hold the exclusive latch or any shared latches. The debug checks
      are available also with SUX_LOCK_GENERIC (in environments that do not
      implement a futex-like system call).
      
      dict_sys_t::latch: Use srw_lock_debug in debug builds.
      This makes the debug fields latch_ex, latch_readers redundant.
      
      fil_space_t::latch: Use srw_lock_debug in debug builds.
      This makes the debug field latch_count redundant.
      The field latch_owner must be preserved, because
      fil_space_t::is_owner() is being used in all builds.
      
      lock_sys_t::latch: Use srw_lock_debug in debug builds.
      This makes the debug fields writer, readers redundant.
      
      lock_sys_t::is_holder(): A new debug predicate to check if
      the current thread is holding lock_sys.latch in any mode.
      
      trx_rseg_t::latch: Use srw_lock_debug in debug builds.
      5f2dcd11
    • mariadb-DebarunBanerjee's avatar
      MDEV-33274 The test encryption.innodb-redo-nokeys often fails · 5e704706
      mariadb-DebarunBanerjee authored
      If we fail to open a tablespace while looking for FILE_CHECKPOINT, we
      set the corruption flag. Specifically, if encryption key is missing, we
      would not be able to open an encrypted tablespace and the flag could be
      set. We miss checking for this flag and report "Missing FILE_CHECKPOINT"
      
      Address review comment to improve the test. Flush pages before starting
      no-checkpoint block. It should improve the number of cases where the
      test is skipped because some intermediate checkpoint is triggered.
      5e704706
    • Daniel Lenski's avatar
      Fix inconsistent definition of... · 6e406bb6
      Daniel Lenski authored
      Fix inconsistent definition of PERFORMANCE_SCHEMA.REPLICATION_APPLIER_STATUS.COUNT_TRANSACTIONS_RETRIES column
      
      This column (`COUNT_TRANSACTIONS_RETRIES`) is defined as `BIGINT UNSIGNED`
      (64-bit unsigned integer) in the user-visible SQL definition:
      https://github.com/MariaDB/server/blob/182ff21ace34ea4f00fb5b66689b172323d91f99/storage/perfschema/table_replication_applier_status.cc#L66
      
          "COUNT_TRANSACTIONS_RETRIES BIGINT unsigned not null comment 'The number of retries that were made because the replication SQL thread failed to apply a transaction.',"
      
      And its value is internally set/updated using the `set_field_ulonglong`
      function:
      https://github.com/MariaDB/server/blob/182ff21ace34ea4f00fb5b66689b172323d91f99/storage/perfschema/table_replication_applier_status.cc#L231-L233
      
          case 3: /* total number of times transactions were retried */
            set_field_ulonglong(f, m_row.count_transactions_retries);
            break;
      
      … but the structure where it is stored allocates only `ulong` for it:
      https://github.com/MariaDB/server/blob/182ff21ace34ea4f00fb5b66689b172323d91f99/storage/perfschema/table_replication_applier_status.h#L62
      
          ulong count_transactions_retries;
      
      As a result of this inconsistency:
      
      1. On any platform where `ulong` is `uint32_t` and `ulonglong` is `uint64_t`,
         setting this value would corrupt the 4 bytes of memory *following* the 4
         bytes actually allocated for it.
      
         Likely this problem was never noticed because this is the final element in
         the structure, and the structure is padded by the compiler to prevent
         memory corruption errors.
      
      2. On any BIG-ENDIAN platform where `ulong` is `uint32_t` and `ulonglong`
         is `uint64_t`, reading back the value of this column will result in
         total garbage.
      
         Likely this problem was never noticed because MariaDB has not been
         tested on 32-bit big-endian platforms.
      
      In order not to affect the user-visible/SQL definition of this column, the
      correct way to fix this issue is to change it to `ulonglong` in the
      structure definition.  See
      https://github.com/MariaDB/server/pull/2763/files#r1329110832 for the
      original identification and discussion of this issue.
      
      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
      6e406bb6
    • Robin Newhouse's avatar
      Fix ninja build for cracklib_password_check · 68c0f6d8
      Robin Newhouse authored
      As was done in dc771113 for `support-files/CMakeLists.txt`
      Do not rely on existence of `CMakeFiles/${target}.dir` directory
      existence. It is not there for custom targets in Ninja build.
      
      This regression was introduced in #1131 which likely copied the pattern
      from e79e8406 before that regression was addressed in dc771113.
      
      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.
      68c0f6d8
  2. 07 Feb, 2024 9 commits
    • mariadb-DebarunBanerjee's avatar
      MDEV-33023 Crash in mariadb-backup --prepare --export after --prepare · fb9da7f7
      mariadb-DebarunBanerjee authored
      mariadb-backup with --prepare option could result in empty redo log
      file. When --prepare is followed by --prepare --export, we exit early
      in srv_start function without opening the ibdata1 tablespace. Later
      while trying to read rollback segment header page, we hit the debug
      assert which claims that the system space should already have been
      opened.
      
      There are two assert cases here.
      
      Issue-1: System tablespace object is not there in fil space hash i.e.
      srv_sys_space.open_or_create() is not called.
      
      Issue-2: The system tablespace data file ibdata1 is not opened i.e.
      fil_system.sys_space->open() is not called.
      
      Fix: For empty redo log and restore operation, open system tablespace
      before returning.
      fb9da7f7
    • Marko Mäkelä's avatar
      Cleanup: Remove ut_format_name() · 8d54d173
      Marko Mäkelä authored
      This follows up commit 383f77cd
      which simplified dict_table_schema_check().
      
      Note: We can display quoted names like this:
      my_snprintf(buf, sizeof buf, "%`.*s.%`s",
                  int(t->name.dblen()), t->name.m_name, t->name.basename());
      8d54d173
    • Marko Mäkelä's avatar
      Merge 10.5 into 10.6 · 91a2192b
      Marko Mäkelä authored
      91a2192b
    • Vlad Lesin's avatar
      MDEV-33004 innodb.cursor-restore-locking test fails · f5373db8
      Vlad Lesin authored
      THE FIX MUST NOT BE MERGED TO 10.6+, BECAUSE 10.6+ IS NOT AFFECTED!
      
      The test is waiting for delete-marked record purging. But this does not
      happen under the following conditions:
      
      1. "START TRANSACTION WITH CONSISTENT SNAPSHOT" - is active, has not
      been rolled back yet
      2. "DELETE FROM t WHERE b = 20 # trx_1" - is committed
      3. "INSERT INTO t VALUES(10, 20) # trx_2" - hanging on
      "ib_after_row_insert" sync point, waiting for "first_ins_cont" signal
      4. "DELETE FROM t WHERE b = 20 # trx_3" - blocked on delete-marked by
      trx_1 record, waiting for trx_2
      5. connection "default" is waiting on
      'now WAIT_FOR row_purge_del_mark_finished'
      
      purge_coordinator_callback_low() sets
      
      purge_state.m_history_length= srv_do_purge(&n_total_purged);
      
      even if nothing was purged, like in our case. Nothing was purged because
      transaction with consistent snapshot was still alive during purging
      procedure.
      
      Then purge_coordinator_timer_callback() does not wake purge thread if
      the following condition is true:
      
      purge_state.m_history_length == trx_sys.rseg_history_len
      
      The above condition is true for our case, because we are waiting for
      delete-marked record purging, and trx_sys.rseg_history_len does not
      grow.
      
      Only 10.5 is affected, because there is no such condition in 10.6, i.e.
      purge thread is woken up even if history size was not changed during
      purge coordinator thread suspending.
      
      The easiest way to fix it is just to remove the test from 10.5.
      f5373db8
    • Thirunarayanan Balathandayuthapani's avatar
      MDEV-33341 innodb.undo_space_dblwr test case fails with Unknown Storage Engine InnoDB · c31b1ee2
      Thirunarayanan Balathandayuthapani authored
      - Failed to reset the innodb_fil_make_page_dirty_debug variable in
      innodb_saved_page_number_debug_basic test case.
      c31b1ee2
    • Oleksandr Byelkin's avatar
      f30244d1
    • Yuchen Pei's avatar
    • Daniel Black's avatar
      MDEV-33397: Innodb include OS error information when failing to write to iblogfileX · e06b159f
      Daniel Black authored
      Without an OS error it could one of the many errors from write.
      e06b159f
    • Alexander Barkov's avatar
      MDEV-33392 Server crashes when using RANDOM_BYTES function and GROUP BY clause... · c4c16777
      Alexander Barkov authored
      MDEV-33392 Server crashes when using RANDOM_BYTES function and GROUP BY clause on a column with a negative value
      
      Item_func_random_bytes did not set its NULL-ability flag.
      c4c16777
  3. 06 Feb, 2024 8 commits
  4. 05 Feb, 2024 2 commits
    • Brandon Nesterenko's avatar
      MDEV-32551: Fix engines/funcs.rpl_session_var · bde552ae
      Brandon Nesterenko authored
      MDEV-32551 changed rpl/t/rpl_session_var.test to show its
      semi-sync status, as it added a semi-sync version of the
      test (rpl_session_var2). The result was re-recorded in the
      rpl suite, but there is an engines/funcs counter-part result
      file that uses the same .test file which also needed to be
      re-recorded.
      bde552ae
    • Yuchen Pei's avatar
      MDEV-33242 Make Spider init queries compatible with non-default old_mode · 1031c884
      Yuchen Pei authored
      Add UTF8_IS_UTF8MB3 to the (session) old_mode in connections made with
      sql service to run init queries
      
      The connection is new and the global variable value takes effect
      rather than the session value from the caller of spider_db_init
      1031c884
  5. 04 Feb, 2024 1 commit
    • Igor Babaev's avatar
      MDEV-31361 Wrong result on 2nd execution of PS for query with derived table · 6fadbf8e
      Igor Babaev authored
      This bug led to wrong result sets returned by the second execution of
      prepared statements from selects using mergeable derived tables pushed
      into external engine. Such derived tables are always materialized. The
      decision that they have to be materialized is taken late in the function
      mysql_derived_optimized(). For regular derived tables this decision is
      usually taken at the prepare phase. However in some cases for some derived
      tables this decision is made in mysql_derived_optimized() too. It can be
      seen in the code of mysql_derived_fill() that for such a derived table it's
      critical to change its translation table to tune it to the fields of the
      temporary table used for materialization of the derived table and this
      must be done after each refill of the derived table. The same actions are
      needed for derived tables pushed into external engines.
      
      Approved by Oleksandr Byelkin <sanja@mariadb.com>
      6fadbf8e
  6. 02 Feb, 2024 6 commits
    • Sergei Petrunia's avatar
      Make innodb_ext_key test stable: use innodb_stable_estimates.inc · 9d0b79c5
      Sergei Petrunia authored
      @@ -314,7 +314,7 @@
       select straight_join * from t0, part ignore index (primary)
       where p_partkey=t0.a and p_size=1;
       id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
      -1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	5	Using where
      +1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	6	Using where
       1	SIMPLE	part	eq_ref	i_p_size	i_p_size	9	const,dbt3_s001.t0.a	1
      9d0b79c5
    • Sergei Petrunia's avatar
      MDEV-33314: Crash in calculate_cond_selectivity_for_table() with many columns · 5972f5c2
      Sergei Petrunia authored
      Variant#3: moved the logic out of create_key_parts_for_pseudo_indexes
      
      Range Analyzer (get_mm_tree functions) can only process up to MAX_KEY=64
      indexes. The problem was that calculate_cond_selectivity_for_table used
      it to estimate selectivities for columns, and since a table can
      have > MAX_KEY columns, would invoke Range Analyzer with more than MAX_KEY
      "pseudo-indexes".
      
      Fixed by making calculate_cond_selectivity_for_table() to run Range
      Analyzer with at most MAX_KEY pseudo-indexes. If there are more
      columns to process, Range Analyzer will be invoked multiple times.
      
      Also made this change:
      -    param.real_keynr[0]= 0;
      +    MEM_UNDEFINED(&param.real_keynr, sizeof(param.real_keynr));
      
      Range Analyzer should have no use on real_keynr when it is run with
      pseudo-indexes.
      5972f5c2
    • Vladislav Vaintroub's avatar
      MDEV-33374 main.mysql_connector_net fails on new Windows 11 · c79f19a5
      Vladislav Vaintroub authored
      Additionally pass `-ExecutionPolicy Bypass` to powershell.exe when
      executing script
      c79f19a5
    • Marko Mäkelä's avatar
      MDEV-33361 Excessive delays in SET GLOBAL innodb_log_file_size · 93189df4
      Marko Mäkelä authored
      innodb_log_file_size_update(): Wait for buf_pool.done_flush_list
      (that a flush batch has completed), not buf_pool.do_flush_list
      (that the buf_flush_page_cleaner was woken up).
      
      The condition variable buf_pool.done_flush_list is broadcast by the
      buf_flush_page_cleaner() at the end of each batch, which is when the
      log checkpoint can advance and where any log resizing may be completed.
      The purpose of the condition variable buf_pool.do_flush_list is to
      wake up the buf_flush_page_cleaner() thread because there is work to do.
      If no thread is signaling that condition variable, this loop could
      unnecessarily wait for up to 5 seconds too long for the log resizing
      to be completed. By consuming signals it could also prevent the
      buf_flush_page_cleaner() thread from waking up.
      
      Tested by: Matthias Leich
      93189df4
    • Daniel Black's avatar
      MDEV-33095 MariaDB-backup - no OS_DATA_FILE_NO_O_DIRECT on some platforms · ea9a6a14
      Daniel Black authored
      Postfix for a6290a5b, in 10.11
      where OS_DATA_FILE_NO_O_DIRECT gets used. Same #ifdef conditions
      as other uses of OS_DATA_FILE_NO_O_DIRECT.
      
      Noticed on aarch64-macos builder.
      ea9a6a14
    • Alexander Barkov's avatar
      MDEV-32893 mariadb-backup is not considering O/S user when --user option is omitted · 78662dda
      Alexander Barkov authored
      mariadb-backup:
      
      Adding a function get_os_user() to detect the OS user name
      if the user name is not specified, to make mariadb-backup:
      - work like MariaDB client tools work
      - match its --help page, which says:
      
        -u, --user=name This option specifies the username used when
        connecting to the server, if that's not the current user.
      78662dda
  7. 01 Feb, 2024 3 commits