1. 28 Mar, 2022 4 commits
    • Marko Mäkelä's avatar
      MDEV-28181 The innochecksum -w option was inadvertently removed · b2fa874e
      Marko Mäkelä authored
      In commit 7a4fbb55 (MDEV-25105)
      the innochecksum option --write (-w) was removed altogether.
      It should have been made a Boolean option, so that old data files
      may be converted to a format that is compatible with
      innodb_checksum_algorithm=strict_crc32 by executing the following:
      
      innochecksum -n -w ibdata* */*.ibd
      
      It would be better to use an older-version innochecksum
      for such a conversion, so that page checksums will be validated
      before updating the checksum.
      
      It never was possible for innochecksum to convert files to the
      innodb_checksum_algorithm=full_crc32 format that is the default
      for new InnoDB data files.
      b2fa874e
    • Marko Mäkelä's avatar
      MDEV-27234: Data dictionary recovery was not READ COMMITTED · 8f8ba758
      Marko Mäkelä authored
      This also fixes MDEV-20198: Instant ALTER TABLE is not crash safe
      
      InnoDB dictionary recovery wrongly used the READ UNCOMMITTED isolation
      level, causing some mismatch. For example, if a table was renamed or
      replaced in a transaction, according to READ UNCOMMITTED the table might
      not exist at all.
      
      We implement READ COMMITTED isolation level for accessing the dictionary
      tables SYS_TABLES, SYS_COLUMNS, SYS_INDEXES, SYS_FIELDS, SYS_VIRTUAL,
      SYS_FOREIGN, SYS_FOREIGN_COLS. For most of these tables, no secondary
      index exists. For the secondary indexes (on SYS_TABLES.ID,
      SYS_FOREIGN.FOR_NAME, SYS_FOREIGN.REF_NAME), we will always look up
      the primary key in the clustered index and check if the record actually
      is a committed version.
      
      dict_check_sys_tables(): Recover tablespaces also from delete-marked
      committed records, so that if a matching .ibd file exists, it will
      be removed by fil_delete_tablespace() when the committed delete-marked
      SYS_INDEXES record of the clustered index is purged
      in row_purge_remove_clust_if_poss_low().
      
      fil_ibd_open(): Change the Boolean parameter "validate" to a ternary
      one, to suppress error messages when the file might not exist.
      It is possible that a .ibd file was deleted and the server shut down
      before the SYS_INDEXES and SYS_TABLES records were purged. Hence, if
      dict_check_sys_tables() finds a committed delete-marked record,
      we must not complain if the tablespace file is not found.
      On Windows, we msut treat ERROR_PATH_NOT_FOUND (directory not found)
      in the same way as ERROR_FILE_NOT_FOUND. This fixes a few failures where
      a previous test successfully executed DROP DATABASE (and deleted all
      files and the directory), but a committed delete-marked SYS_TABLES
      record had not been purged before server restart.
      
      dict_getnext_system_low(): Do not filter out delete-marked records.
      
      dict_startscan_system(), dict_getnext_system(): Do filter out
      delete-marked records, for accessing the INFORMATION_SCHEMA tables.
      
      dict_sys_tables_rec_read(): Return the DB_TRX_ID of the committed
      version of the record. This is needed in dict_load_table_low().
      
      dict_load_foreign_cols(), dict_load_foreign(): Add a parameter for
      the current transaction identifier. In some DDL operations, the
      FOREIGN KEY constraints are being loaded from the data dictionary
      before the DDL transaction has been committed. For SYS_FOREIGN
      and SYS_FOREIGN_COLS, we must implement the special case of
      READ COMMITTED that the changes of the uncommitted current transaction
      are visible.
      
      dict_load_foreign(): Validate the table name. We could find a
      SYS_FOREIGN.ID via a committed delete-marked secondary index record
      that does not match the REF_NAME or FOR_NAME of the secondary index record.
      
      dict_load_index_low(): Optionally take the table as a parameter,
      so that table->def_trx_id can be updated in case of a
      committed delete-marked SYS_INDEXES record corresponding
      to DROP INDEX, but not corresponding to an index stub of ADD INDEX.
      
      dict_load_indexes(): Do not update table->def_trx_id
      in case of delete-marked records.
      
      rec_is_metadata(), rec_offs_make_valid(), rec_get_offsets_func(),
      row_build_low(): Relax some assertions. We may now have
      !index->is_instant() even if a metadata record is present in the index.
      Previously, the recovery of instant ADD/DROP COLUMN assumed
      that READ UNCOMMITTED of the data dictionary will be performed.
      Now, we will have a READ COMMITTED copy of the data dictionary
      cache, and a READ UNCOMMITTED copy of the metadata record.
      
      btr_page_reorganize_low(): Correctly update the FIL_PAGE_TYPE
      when rolling back an instant ADD/DROP COLUMN operation.
      
      row_rec_to_index_entry_impl(): Relax some assertions,
      and disallow accessing "extra" fields. This fixes the recovery
      of a crash during an instant ADD COLUMN after a successful
      instant DROP COLUMN, in the test innodb.instant_alter_crash.
      
      Tested by: Matthias Leich
      8f8ba758
    • Marko Mäkelä's avatar
      2ab94108
    • Marko Mäkelä's avatar
      Fix main.create_or_replace better · a6dbb6b2
      Marko Mäkelä authored
      InnoDB background statistics recalculation may acquire
      a metadata also on the table itself, not only on the tables
      that store the statistics.
      
      Hence, it is better to disable InnoDB persistent statistics altogether.
      This fixes up commit 9b8d9a1d.
      a6dbb6b2
  2. 25 Mar, 2022 6 commits
  3. 24 Mar, 2022 3 commits
    • Rucha Deodhar's avatar
      MDEV-27819: func_2.xxx_charset skipped after renaming utf8 to utf8mb3 · 0da5f45a
      Rucha Deodhar authored
      Analysis: utf8 character set is now utf8mb3 or utf8mb4. So charset_master
      is not able to find utf8 at the beginning of test. Hence it skips the tests
      that use charset_master.
      Fix: rename utf8 to utf8mb3 in charset_master.
      0da5f45a
    • Marko Mäkelä's avatar
      MDEV-28137 Some memory transactions are unnecessarily complex · 8684af76
      Marko Mäkelä authored
      buf_page_get_zip(): Do not perform a system call inside a
      memory transaction. Instead, if the page latch is unavailable,
      abort the memory transaction and let the fall-back code path
      wait for the page latch.
      
      buf_pool_t::watch_remove(): Return the previous state of the block.
      
      buf_page_init_for_read(): Use regular stores for moving the
      buffer fix count of watch_remove() to the new block descriptor.
      
      A more extensive version of this was reviewed by Daniel Black
      and tested with Intel TSX-NI by Axel Schwenke and Matthias Leich.
      My assumption that regular loads and stores would execute faster
      in a memory transaction than operations like std::atomic::fetch_add()
      turned out to be incorrect.
      8684af76
    • Marko Mäkelä's avatar
      MDEV-23974 fixup: rpl.rpl_gtid_stop_start fails · b101f19d
      Marko Mäkelä authored
      The call mtr.add_suppression() that was added
      in commit 75b7cd68
      for MemorySanitizer and Valgrind runs is causing
      a result difference for the test rpl.rpl_gtid_stop_start.
      Let us disable the binlog for executing that statement.
      
      Also, the test perfschema.statement_program_lost_inst
      would fail due to the changes to have_innodb.inc in this commit.
      To compensate for that, we will make more --suite=perfschema
      tests run without InnoDB, and explicitly enable InnoDB in
      those tests that depend on a transactional storage engine.
      b101f19d
  4. 23 Mar, 2022 4 commits
  5. 22 Mar, 2022 2 commits
    • Andrei's avatar
      MDEV-27760 event may non stop replicate in circular semisync setup · 5ccd845d
      Andrei authored
      MDEV-21117 had to relax own events acceptance condition for a case
      when a former semisync master server recovers after crash as the
      semisync slave. That however admitted a possibility for endless event
      "orbiting" in the non-strict slave gtid mode of semisync circular
      setup.
      
      The same server-id event termination is restored now for
      the non-strict gtid mode to follow regular rules (that is it's ignored
      unless @@global.replicate_same_server_id allows it in).
      
      To address MDEV-21117 recovery agenda,
      in the strict gtid mode and the transaction's gtid ordered strictly
      greater than the current slave gtid state, the same server-id
      transaction is accepted.
      
      The gtid strict mode is safe to accept transactions even if
      the slave state were not set correct by the user, e.g
      at the former master.
      An added test shows a typical out-of-order error at execution so
      no data corruption is guaranteed in such a case.
      5ccd845d
    • Julius Goryavsky's avatar
  6. 18 Mar, 2022 3 commits
    • Marko Mäkelä's avatar
      MDEV-27909 InnoDB: Failing assertion: state == TRX_STATE_NOT_STARTED ... on DDL · 8840583a
      Marko Mäkelä authored
      The fix in commit 6e390a62 (MDEV-26772)
      was a step to the right direction, but implemented incorrectly.
      When an InnoDB persistent statistics table cannot be locked immediately,
      we must not let row_mysql_handle_errors() to roll back the transaction.
      
      lock_table_for_trx(): Add the parameter no_wait (default false)
      for an immediate return of DB_LOCK_WAIT in case of a conflict.
      
      ha_innobase::delete_table(), ha_innobase::rename_table():
      Pass no_wait=true to lock_table_for_trx() when needed,
      instead of temporarily setting THDVAR(thd, lock_wait_timeout) to 0.
      8840583a
    • Otto Kekäläinen's avatar
      Deb: Sync Salsa-CI from Debian MariaDB 10.5 repository · 9595ea89
      Otto Kekäläinen authored
      Since Debian Sid now has MariaDB 10.6, we can't do any upgrade tests in
      Debian Sid for the 10.5 branch anymore. It would just fail with downgrade
      errors.
      
      Also, since MariaDB 10.5 is no longer in Sid, we can't even test 10.5.x
      to 10.5.y upgrades in Sid.
      
      Instead the 10.5 branch salsa-ci.yml should run all builds and tests based
      on Debian Bullseye, which has MariaDB 10.5 (only).
      
      To achieve this, essentially sync most the the salsa-ci.yml contents from
      https://salsa.debian.org/mariadb-team/mariadb-10.5/-/tree/bullseye
      
      Also add a couple Lintian overrides to make Salsa-CI pass.
      
      NOTE TO MERGERS: This commit is intended for the 10.5 branch only, do not
      merge anything from it on 10.6 or any other branch.
      9595ea89
    • Daniel Black's avatar
      Merge branch 10.5 into 10.6 · 065f995e
      Daniel Black authored
      065f995e
  7. 17 Mar, 2022 2 commits
  8. 16 Mar, 2022 5 commits
  9. 15 Mar, 2022 10 commits
    • Daniel Black's avatar
      MDEV-27955 main.func_json_notembedded test fails on out-of-memory · b2c81e06
      Daniel Black authored
      Uses 500M+ of memory by repeating an 8 byte sequence 62.5M times.
      
      Reduce the number of repeats on string reduced by 100 times.
      
      Tested by applying against the reverted MDEV-24909 code. 1000 times
      reduction was too much, but 100 still managed to trigger the bug.
      b2c81e06
    • Daniel Black's avatar
      MDEV-23915 ER_KILL_DENIED_ERROR not passed a thread id (part 2) · 57dbe878
      Daniel Black authored
      Per Marko's comment in JIRA, sql_kill is passing the thread id
      as long long. We change the format of the error messages to match,
      and cast the thread id to long long in sql_kill_user.
      57dbe878
    • Daniel Black's avatar
      MDEV-23915 ER_KILL_DENIED_ERROR not passed a thread id · 99837c61
      Daniel Black authored
      The 10.5 test error main.grant_kill showed up a incorrect
      thread id on a big endian architecture.
      
      The cause of this is the sql_kill_user function assumed the
      error was ER_OUT_OF_RESOURCES, when the the actual error was
      ER_KILL_DENIED_ERROR. ER_KILL_DENIED_ERROR as an error message
      requires a thread id to be passed as unsigned long, however a
      user/host was passed.
      
      ER_OUT_OF_RESOURCES doesn't even take a user/host, despite
      the optimistic comment. We remove this being passed as an
      argument to the function so that when MDEV-21978 is implemented
      one less compiler format warning is generated (which would
      have caught this error sooner).
      
      Thanks Otto for reporting and Marko for analysis.
      99837c61
    • Marko Mäkelä's avatar
      Merge 10.5 into 10.6 · 4ef44cc2
      Marko Mäkelä authored
      4ef44cc2
    • Marko Mäkelä's avatar
      MDEV-27985 buf_flush_freed_pages() causes InnoDB to hang · 73fee39e
      Marko Mäkelä authored
      buf_flush_freed_pages(): Assert that neither buf_pool.mutex
      nor buf_pool.flush_list_mutex are held. Simplify the loops.
      Return the tablespace and the number of pages written or punched.
      
      buf_flush_LRU_list_batch(), buf_do_flush_list_batch():
      Release buf_pool.mutex before invoking buf_flush_space().
      
      buf_flush_list_space(): Acquire the mutexes only after invoking
      buf_flush_freed_pages().
      
      Reviewed by: Thirunarayanan Balathandayuthapani
      73fee39e
    • Marko Mäkelä's avatar
      MDEV-25214 Crash in fil_space_t::try_to_close · 00896db1
      Marko Mäkelä authored
      fil_space_t::try_to_close(): Tolerate a tablespace that has no
      data files attached. The function fil_ibd_create() initially
      creates and attaches a tablespace with no files, and invokes
      fil_space_t::add() later.
      
      fil_node_open_file(): After releasing and reacquiring fil_system.mutex,
      check if the file was already opened by another thread. This avoids
      an assertion failure !node->is_open() in fil_node_open_file_low().
      
      These failures were reproduced with the test
      innodb.table_definition_cache_debug and the fix of MDEV-27985.
      00896db1
    • Marko Mäkelä's avatar
      Merge 10.4 into 10.5 · e1246775
      Marko Mäkelä authored
      e1246775
    • Marko Mäkelä's avatar
      Merge 10.3 into 10.4 · 9c6135e8
      Marko Mäkelä authored
      9c6135e8
    • Daniel Black's avatar
      Merge 10.2 (part) into 10.3 · a9500860
      Daniel Black authored
      commit '6de482a6'
      
      10.3 no longer errors in truncate_notembedded.test
      but per comments, a non-crash is all that we are after.
      a9500860
    • Hugo Wen's avatar
      MDEV-27342: Fix issue of recovery failure using new server id · dafc5fb9
      Hugo Wen authored
      Commit 6c39eaeb made the crash recovery dependent on server_id.
      The crash recovery could fail when restoring a new instance from
      original crashed data directory USING A NEW SERVER ID.
      
      The issue doesn't exist in previous major versions before 10.6.
      
      Root cause is when generating the input XID to be searched in the hash,
      server id is populated with the current server id.
      So if the server id changed when recovering, the XID couldn't be found
      in the hash due to server id doesn't match.
      
      This fix is to use original server id when creating the input XID
      object in function `xarecover_do_commit_or_rollback`.
      
      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.
      dafc5fb9
  10. 14 Mar, 2022 1 commit