1. 11 Apr, 2024 2 commits
    • Sergei Golubchik's avatar
      Merge branch '10.5' into 10.6 · 41296a07
      Sergei Golubchik authored
      41296a07
    • Marko Mäkelä's avatar
      MDEV-33325 Crash in flst_read_addr on corrupted data · 263932d5
      Marko Mäkelä authored
      flst_read_addr(): Remove assertions. Instead, we will check these
      conditions in the callers and avoid a crash in case of corruption.
      We will check the conditions more carefully, because the callers
      know more exact bounds for the page numbers and the byte offsets
      withing pages.
      
      flst_remove(), flst_add_first(), flst_add_last(): Add a parameter
      for passing fil_space_t::free_limit. None of the lists may point to
      pages that are beyond the current initialized length of the
      tablespace.
      
      trx_rseg_mem_restore(): Access the first page of the tablespace,
      so that we will correctly recover rseg->space->free_limit
      in case some log based recovery is pending.
      
      ibuf_remove_free_page(): Only look up the root page once, and
      validate the last page number.
      
      Reviewed by: Debarun Banerjee
      263932d5
  2. 10 Apr, 2024 7 commits
    • Sergei Golubchik's avatar
      sporadic failures of rpl.rpl_semi_sync_master_shutdown · 2d2172a5
      Sergei Golubchik authored
      increase the MASTER_CONNECT_RETRY time under valgrind,
      otherwise the slave gives up retrying before the master is ready
      
      also, cosmetic cleanup of rpl_semi_sync_master_shutdown.test
      2d2172a5
    • Andrei's avatar
      MDEV-31779 Server crash in Rows_log_event::update_sequence upon replaying binary log · 0da1653f
      Andrei authored
      The crash at running mysqlbinlog on a SEQUENCE containing binlog file
      was caused MDEV-29621 fixes that did not check which of the slave
      or binlog applier executes a block introduced there.
      
      The block is meaningful only for the parallel slave applier, so
      it's safe to fix this bug with identified the actual applier and
      skipping the block when it's the mysqlbinlog one.
      0da1653f
    • Monty's avatar
      Fixed calculating of last_master_timestamp for parallel replication. · da47c037
      Monty authored
      This effects the Seconds_Behind_Master value.
      da47c037
    • Monty's avatar
      MDEV-33813 ERROR 1021 (HY000): Disk full (./org/test1.MAI); waiting for someone to free some space · 3655cefc
      Monty authored
      Fixed that internal temporary tables are not waiting for freed disk space.
      
      Other things:
      - 'kill id' will now kill a query waiting for free disk space instantly.
        Before it could take up to 60 seconds for the kill would be noticed.
      - Fixed that sorting one index is not using MY_WAIT_IF_FULL for temp files.
      - Fixed bug where share->write_flag set MY_WAIT_IF_FULL for temp files.
      
      It is quite hard to do a test case for this. Instead I tested all
      combinations interactively.
      3655cefc
    • Alexander Barkov's avatar
      MDEV-29149 Assertion `!is_valid_datetime() ||... · b697dce8
      Alexander Barkov authored
      MDEV-29149 Assertion `!is_valid_datetime() || fraction_remainder(((item->decimals) < (6) ? (item->decimals) : (6))) == 0' failed in Datetime_truncation_not_needed::Datetime_truncation_not_needed
      
      TIME-alike string and numeric arguments to TIMEDIFF()
      can get additional fractional seconds during the supported
      TIME range adjustment in get_time().
      
      For example, during TIMEDIFF('839:00:00','00:00:00') evaluation
      in Item_func_timediff::get_date(), the call for args[0]->get_time()
      returns MYSQL_TIME '838:59:59.999999'.
      
      Item_func_timediff::get_date() did not handle these extra digits
      and returned a MYSQL_TIME result with fractional digits outside
      of Item_func_timediff::decimals. This mismatch could further be
      caught by a DBUG_ASSERT() in various other pieces of the code,
      leading to a crash.
      
      Fix:
      
      In case if get_time() returned MYSQL_TIMESTAMP_TIME,
      let's truncate all extra digits using my_time_trunc(&l_time,decimals).
      This guarantees that the rest of the code returns a MYSQL_TIME
      with second_part not conflicting with Item_func_timediff::decimals.
      b697dce8
    • Jan Lindström's avatar
      MDEV-25089 : Assertion `error.len > 0' failed in galera::ReplicatorSMM::handle_apply_error() · 0304dbc3
      Jan Lindström authored
      Additional corrections after merge from 10.4 branch
      Signed-off-by: default avatarJulius Goryavsky <julius.goryavsky@mariadb.com>
      0304dbc3
    • Alexander Barkov's avatar
      MDEV-28366 GLOBAL debug_dbug setting affected by collation_connection=utf16... · 9fb8881e
      Alexander Barkov authored
      When the system variables @@debug_dbug was assigned to
      some expression, Sys_debug_dbug::do_check() did not properly
      convert the value from the expression character set to utf8.
      So the value was erroneously re-interpretted as utf8 without
      conversion. In case of a tricky expression character set
      (e.g. utf16le), this led to unexpected results.
      
      Fix:
      
      Re-using Sys_var_charptr::do_string_check() in Sys_debug_dbug::do_check().
      9fb8881e
  3. 09 Apr, 2024 12 commits
    • Brandon Nesterenko's avatar
      MDEV-30260: Slave crashed:reload_acl_and_cache during shutdown · 952ab9a5
      Brandon Nesterenko authored
      The signal handler thread can use various different runtime
      resources when processing a SIGHUP (e.g. master-info information)
      due to calling into reload_acl_and_cache(). Currently, the shutdown
      process waits for the termination of the signal thread after
      performing cleanup. However, this could cause resources actively
      used by the signal handler to be freed while reload_acl_and_cache()
      is processing.
      
      The specific resource that caused MDEV-30260 is a race condition for
      the hostname_cache, such that mysqld would delete it in
      clean_up()::hostname_cache_free(), before the signal handler would
      use it in reload_acl_and_cache()::hostname_cache_refresh().
      
      Another similar resource is the active_mi/master_info_index. There
      was a race between its deletion by the main thread in end_slave(),
      and their usage by the Signal Handler as a part of
      Master_info_index::flush_all_relay_logs.read(active_mi) in
      reload_acl_and_cache().
      
      This patch fixes these race conditions by relocating where server
      shutdown waits for the signal handler to die until after
      server-level threads have been killed (i.e., as a last step of
      close_connections()). With respect to the hostname_cache, active_mi
      and master_info_cache, this ensures that they cannot be destroyed
      while the signal handler is still active, and potentially using
      them.
      
      Additionally:
      
       1) This requires that Events memory is still in place for SIGHUP
      handling's mysql_print_status(). So event deinitialization is moved
      into clean_up(), but the event scheduler still needs to be stopped
      in close_connections() at the same spot.
      
       2) The function kill_server_thread is no longer used, so it is
      deleted
      
       3) The timeout to wait for the death of the signal thread was not
      consistent with the comment. The comment mentioned up to 10 seconds,
      whereas it was actually 0.01s. The code has been fixed to wait up to
      10 seconds.
      
       4) A warning has been added if the signal handler thread fails to
      exit in time.
      
       5) Added pthread_join() to end of wait_for_signal_thread_to_end()
      if it hadn't ended in 10s with a warning. Note this also removes
      the pthread_detached attribute from the signal_thread to allow
      for the pthread_join().
      
      Reviewed By:
      ===========
      Vladislav Vaintroub <wlad@mariadb.com>
      Andrei Elkin <andrei.elkin@mariadb.com>
      952ab9a5
    • Sergei Golubchik's avatar
      MDEV-33867 main.query_cache_debug fails with heap-use-after-free · 4980fcb9
      Sergei Golubchik authored
      What's happening:
      1. Query_cache::insert() locks the QC and verifies that it's enabled
      2. parallel thread tries to disable it. trylock fails (QC is locked)
         so the status becomes DISABLE_REQUEST
      3. Query_cache::insert() calls Query_cache::write_result_data()
         which allocates a new block and unlocks the QC.
      4. Query_cache::unlock() notices there are no more QC users and a
         pending DISABLE_REQUEST so it disables the QC and frees all the
         memory, including the new block that was just allocated
      5. Query_cache::write_result_data() proceeds to write into the freed block
      
      Fix: change m_cache_status under a mutex.
      
      Approved by Oleksandr Byelkin <sanja@mariadb.com>
      4980fcb9
    • Jan Lindström's avatar
      MDEV-25731 : Assertion `mode_ == m_local' failed in void... · 33af5575
      Jan Lindström authored
      MDEV-25731 : Assertion `mode_ == m_local' failed in void wsrep::client_state::streaming_params(wsrep::streaming_context::fragment_unit, size_t)
      
      Problem was that if wsrep_load_data_splitting was used
      streaming replication (SR) parameters were set
      for MyISAM table. Galera does not currently support SR for
      MyISAM.
      
      Fix is to ignore wsrep_load_data_splitting setting (with
      warning) if table is not InnoDB table.
      
      This is 10.6+ case of fix.
      Signed-off-by: default avatarJulius Goryavsky <julius.goryavsky@mariadb.com>
      33af5575
    • Alexander Barkov's avatar
      MDEV-18898 SELECT using wrong index when using operator IN with mixed types · d4936c8b
      Alexander Barkov authored
      These patches:
      
        # commit 74891ed2
        #
        #  MDEV-11514, MDEV-11497, MDEV-11554, MDEV-11555 - IN and CASE type aggregation problems
      
        # commit 53499cd1
        #
        # MDEV-31303 Key not used when IN clause has both signed and usigned values
      
      earlier fixed MDEV-18898.
      
      Adding only an MTR case.
      
      	modified:   mysql-test/main/func_in.result
      	modified:   mysql-test/main/func_in.test
      d4936c8b
    • Jan Lindström's avatar
      MDEV-33828 : Transactional commit not supported by involved engine(s) · 7aa86eb1
      Jan Lindström authored
      Problem was too tight condition on ha_commit_trans to not
      allow non transactional storage engines participate 2pc
      in Galera case. This is required because transaction
      using e.g. procedures might read mysql.proc table inside
      a trasaction and these tables use at the moment Aria
      storage engine that does not support 2pc.
      
      Fixed by allowing read only transactions to storage
      engines that do not support two phase commit to participate
      2pc transaction. These will be committed later separately.
      Signed-off-by: default avatarJulius Goryavsky <julius.goryavsky@mariadb.com>
      7aa86eb1
    • Julius Goryavsky's avatar
      galera: wsrep-lib submodule update · 3003a3da
      Julius Goryavsky authored
      3003a3da
    • Marko Mäkelä's avatar
      MDEV-33802 Weird read view after ROLLBACK of another transaction · 4aa92911
      Marko Mäkelä authored
      Even after commit b8a67198 there
      is an anomaly where a locking read could return inconsistent results.
      If a locking read would have to wait for a record lock, then by the
      definition of a read view, the modifications made by the current lock
      holder cannot be visible in the read view. This is because the read
      view must exclude any transactions that had not been committed at the
      time when the read view was created.
      
      lock_rec_convert_impl_to_expl_for_trx(), lock_rec_convert_impl_to_expl():
      Return an unsafe-to-dereference pointer to a transaction that holds or
      held the lock, or nullptr if the lock was available.
      
      lock_clust_rec_modify_check_and_lock(),
      lock_sec_rec_read_check_and_lock(),
      lock_clust_rec_read_check_and_lock():
      Return DB_RECORD_CHANGED if innodb_strict_isolation=ON and the
      lock was being held by another transaction.
      
      The test case, which is based on a bug report by Zhuang Liu,
      covers the function lock_sec_rec_read_check_and_lock().
      
      Reviewed by: Vladislav Lesin
      4aa92911
    • Marko Mäkelä's avatar
      MDEV-33588 buf::Block_hint is a performance hog · a4cda66e
      Marko Mäkelä authored
      In so-called optimistic buffer pool lookups, we must not
      dereference a block descriptor before we have made sure that
      it is accessible. While buf_pool_t::resize() is running,
      block descriptors could become invalid.
      
      The buf::Block_hint class was essentially duplicating
      a buf_pool.page_hash lookup that was executed in
      buf_page_optimistic_get() anyway. For better locality of
      reference, we had better execute that lookup only once.
      
      buf_page_optimistic_fix(): Prepare for buf_page_optimistic_get().
      This basically is a simpler version of Buf::Block_hint.
      
      buf_page_optimistic_get(): Assume that buf_page_optimistic_fix()
      has been called and the page identifier verified. Should the block
      be evicted, the block->modify_clock will be invalidated; we do not
      need to check the block->page.id() again. It suffices to check
      the block->modify_clock after acquiring the page latch.
      
      btr_pcur_t::old_page_id: Store the expected page identifier
      for buf_page_optimistic_fix().
      
      btr_pcur_t::block_when_stored: Remove. This was duplicating
      page_cur_t::block.
      
      btr_pcur_optimistic_latch_leaves(): Remove redundant parameters.
      First, invoke buf_page_optimistic_fix() on the requested page.
      If needed, acquire a latch on the left page. Finally, acquire
      a latch on the target page and recheck the block->modify_clock.
      If the page had been freed while we were not holding a page latch,
      fall back to the slow path. Validate the FIL_PAGE_PREV after
      acquiring a latch on the current page. The block->modify_clock
      is only being incremented when records are deleted or pages
      reorganized or evicted; it does not guard against concurrent
      page splits.
      
      Reviewed by: Debarun Banerjee
      a4cda66e
    • Alexander Barkov's avatar
      MDEV-18319 BIGINT UNSIGNED Performance issue · 6606abb6
      Alexander Barkov authored
      The patch for MDEV-18319 BIGINT UNSIGNED Performance issue
      fixed this problem in 10.5.23.
      
      This patch adds only an MTR test to cover MDEV-18319.
      6606abb6
    • Kristian Nielsen's avatar
      MDEV-33668: More precise dependency tracking of XA XID in parallel replication · d90a2b44
      Kristian Nielsen authored
      Keep track of each recently active XID, recording which worker it was queued
      on. If an XID might still be active, choose the same worker to queue event
      groups that refer to the same XID to avoid conflicts.
      
      Otherwise, schedule the XID freely in the next round-robin slot.
      
      This way, XA PREPARE can normally be scheduled without restrictions (unless
      duplicate XID transactions come close together). This improves scheduling
      and parallelism over the old method, where the worker thread to schedule XA
      PREPARE on was fixed based on a hash value of the XID.
      
      XA COMMIT will normally be scheduled on the same worker as XA PREPARE, but
      can be a different one if the XA PREPARE is far back in the event history.
      
      Testcase and code for trimming dynamic array due to Andrei.
      Reviewed-by: default avatarAndrei Elkin <andrei.elkin@mariadb.com>
      Signed-off-by: default avatarKristian Nielsen <knielsen@knielsen-hq.org>
      d90a2b44
    • Kristian Nielsen's avatar
      MDEV-33668: Refactor parallel replication round-robin scheduling to use explicit FIFO · f9ecaa87
      Kristian Nielsen authored
      This is a preparatory patch to facilitate the next commit to improve
      the scheduling of XA transactions in parallel replication.
      
      When choosing the scheduling bucket for the next event group in
      rpl_parallel_entry::choose_thread(), use an explicit FIFO for the
      round-robin selection instead of a simple cyclic counter i := (i+1) % N.
      
      This allows to schedule XA COMMIT/ROLLBACK dependencies explicitly without
      changing the round-robin scheduling of other event groups.
      Reviewed-by: default avatarAndrei Elkin <andrei.elkin@mariadb.com>
      Signed-off-by: default avatarKristian Nielsen <knielsen@knielsen-hq.org>
      f9ecaa87
    • Vladislav Vaintroub's avatar
      MDEV-33840 tpool : switch off maintenance timer when not needed. · 09bae92c
      Vladislav Vaintroub authored
      Before patch, maintenance timer will tick every 0.4 seconds.
      After this patch, timer will tick every 0.4 seconds when necessary(
      there are delayed thread creation), switching off completely after 20
      seconds of being idle.
      09bae92c
  4. 08 Apr, 2024 8 commits
    • Yuchen Pei's avatar
      MDEV-33731 Only iterate over m_locked_partitions in update_next_auto_inc_val() · b7b58a23
      Yuchen Pei authored
      Only locked will participate in the query in this case. Chances are
      that not-locked partitions were not opened, which is the cause of the
      crash in the added test case spider/bugfix.mdev_33731 without this
      patch.
      b7b58a23
    • Sergei Golubchik's avatar
    • Sergei Golubchik's avatar
      MDEV-25614 disable failing galera test · 50803bc4
      Sergei Golubchik authored
      50803bc4
    • Sergei Golubchik's avatar
      update C/C · d32b6f69
      Sergei Golubchik authored
      fixes sporadic unit.conc_ps_bugs failures
      d32b6f69
    • Brandon Nesterenko's avatar
      MDEV-33672: Gtid_log_event Construction from File Should Ensure Event Length When Using Extra Flags · 89c907bd
      Brandon Nesterenko authored
      A GTID event can have variable length, with contributing factors
      such as the variable length from the flags2 and optional extra flags
      fields. These fields are bitmaps, where each set bit indicates an
      additional value that should be appended to the event, e.g.
      multi-engine transactions append a number to indicate the number of
      additional engines a transaction uses. However, if a flags bit is
      set, and no additional fields are appended to the event, MDEV-33672
      reports that the server can still try to read from memory as if it
      did exist. Note, however, in debug builds, this condition is
      asserted for FL_EXTRA_MULTI_ENGINE.
      
      This patch fixes this to check that the length of the event is
      aligned with the expectation set by the flags for FL_PREPARED_XA,
      FL_COMPLETED_XA, and FL_EXTRA_MULTI_ENGINE.
      
      Reviewed By
      ============
      Kristian Nielsen <knielsen@knielsen-hq.org>
      89c907bd
    • Rucha Deodhar's avatar
    • Alexander Barkov's avatar
      MDEV-31251 MDEV-30968 breaks running mariabackup on older mariadb (opendir(NULL)) · 11986ec6
      Alexander Barkov authored
      The problem happened when running mariabackup agains a pre-MDEV-30971 server,
      i.e. not having yet the system variable @@aria_log_dir_path.
      
      As a result, backup_start() called the function backup_files_from_datadir()
      with a NULL value, which further caused a crash.
      
      Fix:
      Perform this call:
      
          backup_files_from_datadir(.., aria_log_dir_path, ..)
      
      only if aria_log_dir_path is not NULL. Otherwise,
      assume that Aria log files are in their default location,
      so they've just copied by the previous call:
      
          backup_files_from_datadir(.., fil_path_to_mysql_datadir, ..)
      
      Thanks to Walter Doekes for a patch proposal.
      11986ec6
    • Marko Mäkelä's avatar
      MDEV-33819 The purge of committed history is mis-parsing some log · 73291de7
      Marko Mäkelä authored
      In commit aa719b50 (part of MDEV-32050)
      a bug was introduced in the function purge_sys_t::choose_next_log(),
      which reimplements some logic that previously was part of
      trx_purge_read_undo_rec(). We must invoke trx_undo_get_first_rec()
      with the page number and offset of the undo log header, but we were
      incorrectly invoking it on the current undo page number, which caused
      us to parse undo records starting at an incorrect offset.
      
      purge_sys_t::choose_next_log(): Pass the correct parameter to
      trx_undo_page_get_first_rec().
      
      trx_undo_page_get_next_rec(), trx_undo_page_get_first_rec(),
      trx_undo_page_get_last_rec(): Add debug assertions and make the
      code more robust by returning nullptr on corruption. Should we
      detect any corrupted undo logs during the purge of committed
      transaction history, the sanest thing to do is to pretend that
      the end of an undo log was reached. If any garbage is left in
      the tables, it will be ignored by anything else than
      CHECK TABLE ... EXTENDED, and it can be removed by OPTIMIZE TABLE.
      
      Thanks to Matthias Leich for providing an "rr replay" trace where
      this bug could be found.
      
      Reviewed by: Vladislav Lesin
      73291de7
  5. 07 Apr, 2024 2 commits
  6. 06 Apr, 2024 1 commit
    • Sergei Golubchik's avatar
      sporadic failures of main.mdl_sync · a7bf0a42
      Sergei Golubchik authored
      main.mdl_sync 'innodb'                   w32 [ fail ]
              Test ended at 2024-04-06 14:11:15
      
      CURRENT_TEST: main.mdl_sync
      --- main/mdl_sync.result
      +++ main/mdl_sync.reject
      @@ -2458,6 +2458,7 @@
       SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info;
       LOCK_MODE	LOCK_TYPE	TABLE_SCHEMA	TABLE_NAME
       MDL_BACKUP_FTWRL2	Backup lock
      +MDL_SHARED	Table metadata lock	test	t2
       unlock tables;
       connection default;
       # Reaping UPDATE
      a7bf0a42
  7. 05 Apr, 2024 8 commits
    • Sergei Golubchik's avatar
      mtr: increase more timeouts under debuggers · 12d448fd
      Sergei Golubchik authored
      in particular, debug_sync timeout and wait_for_pos timeout
      12d448fd
    • Sergei Golubchik's avatar
      MDEV-29171 disable failing galera test · 429fdb5b
      Sergei Golubchik authored
      429fdb5b
    • Sergei Golubchik's avatar
      suppress a transient galera warning · 96533bae
      Sergei Golubchik authored
      these warnings are expected and are auto-resolved by galera
      96533bae
    • Sergei Golubchik's avatar
      MDEV-33290: Disable ColumnStore based on boost version (post-postfix) · b3e29da5
      Sergei Golubchik authored
      policy CMP0093 was added in cmake 3.15
      let's support cmake from 2.8.12, that's what our
      CMAKE_MINIMUM_REQUIRED() says
      b3e29da5
    • Daniel Black's avatar
      MDEV-33290: Disable ColumnStore based on boost version (postfix) · 075dd736
      Daniel Black authored
      Its important to fail early and only contine with the include after
      the boost version check succeeds.
      
      Needs to succeed on ealier verisons too so can't just fail if too new.
      As such, do a version check.
      075dd736
    • Sergei Golubchik's avatar
      cleanup: perfschema.threads_history · cb41757f
      Sergei Golubchik authored
      improve debuggability
      cb41757f
    • Sergei Golubchik's avatar
      perfschema is disabled until it's enabled · 19028020
      Sergei Golubchik authored
      as it was thinking it was enabled even if initialize_performance_schema
      wasn't called at all
      19028020
    • Monty's avatar
      Fixed memory leaks in embedded server and mysqltest · 53af3d8c
      Monty authored
      This commit fixes the following issues:
      - memory leak checking enabled for mysqltest. This cover all cases except
        calls to 'die()' that only happens in case of internal failures in
        mysqltest. die() is not called anymore in the result files differs.
      - One can now run mtr --embedded without failures (this crashed or hang
        before)
      - cleanup_and_exit() has a new parameter that indicates that it is called
        from die(), in which case we should not do memory leak checks. We now
        always call cleanup_and_exit() instead of exit() to be able to free up
        memory and discover memory leaks.
      - Lots of new assert to catch error conditions
      - More DBUG statements.
      - Fixed that all results are freed in mysqltest (Fixed a memory leak in
        mysqltest when using prepared statements).
      - Fixed race condition in do_stmt_close() that caused embedded server
        to not free memory. (Memory leak in mysqltest with embedded server).
      - Fixed two memory leaks in embedded server when using prepared statements.
        These memory leaks caused timeout hangs in mtr when server was compiled
        with safemalloc. This issue was not noticed (except as timeouts) as
        memory report checking was done but output of it was disabled.
      53af3d8c