1. 23 Jan, 2023 1 commit
  2. 19 Jan, 2023 3 commits
    • Marko Mäkelä's avatar
      MDEV-30400 Assertion height == btr_page_get_level(...) on INSERT · f9cac8d2
      Marko Mäkelä authored
      This also fixes part of MDEV-29835 Partial server freeze
      which is caused by violations of the latching order that was
      defined in https://dev.mysql.com/worklog/task/?id=6326
      (WL#6326: InnoDB: fix index->lock contention). Unless the
      current thread is holding an exclusive dict_index_t::lock,
      it must acquire page latches in a strict parent-to-child,
      left-to-right order. Not all cases are fixed yet. Failure to
      follow the correct latching order will cause deadlocks of threads
      due to lock order inversion.
      
      As part of these changes, the BTR_MODIFY_TREE mode is modified
      so that an Update latch (U a.k.a. SX) will be acquired on the
      root page, and eXclusive latches (X) will be acquired on all pages
      leading to the leaf page, as well as any left and right siblings
      of the pages along the path. The test innodb.innodb_wl6326
      will be removed, because at the time the DEBUG_SYNC point is hit,
      the thread is actually holding several page latches that will be
      blocking a concurrent SELECT statement.
      
      We also remove double bookkeeping that was caused due to excessive
      information hiding in mtr_t::m_memo. We simply let mtr_t::m_memo
      store information of latched pages, and ensure that
      mtr_memo_slot_t::object is never a null pointer.
      The tree_blocks[] and tree_savepoints[] were redundant.
      
      mtr_t::get_already_latched(): Look up a latched page in mtr_t::m_memo.
      This avoids many redundant entries in mtr_t::m_memo, as well as
      redundant calls to buf_page_get_gen() for blocks that had already
      been looked up in a mini-transaction.
      
      btr_get_latched_root(): Return a pointer to an already latched root page.
      This replaces btr_root_block_get() in cases where the mini-transaction
      has already latched the root page.
      
      btr_page_get_parent(): Fetch a parent page that was already latched
      in BTR_MODIFY_TREE, by invoking mtr_t::get_already_latched().
      If needed, upgrade the root page U latch to X.
      This avoids bloating mtr_t::m_memo as well as redundant
      buf_pool.page_hash lookups. For non-QUICK CHECK TABLE as well as for
      B-tree defragmentation, we will invoke btr_cur_search_to_nth_level().
      
      btr_cur_search_to_nth_level(): This will only be used for non-leaf
      (level>0) B-tree searches that were formerly named BTR_CONT_SEARCH_TREE
      or BTR_CONT_MODIFY_TREE. In MDEV-29835, this function could be
      removed altogether, or retained for the case of
      CHECK TABLE without QUICK.
      
      btr_cur_t::search_leaf(): Replaces btr_cur_search_to_nth_level()
      for searches to level=0 (the leaf level).
      
      btr_cur_t::pessimistic_search_leaf(): Implement the new
      BTR_MODIFY_TREE latching logic in the case that page splits
      or merges will be needed. The parent pages (and their siblings)
      should already be latched on the first dive to the leaf and be
      present in mtr_t::m_memo; there should be no need for
      BTR_CONT_MODIFY_TREE. This pre-latching almost suffices;
      MDEV-29835 will have to revise it and remove work-arounds where
      mtr_t::get_already_latched() fails to find a block.
      
      rtr_search_to_nth_level(): A SPATIAL INDEX version of
      btr_search_to_nth_level() that can search to any level
      (including the leaf level).
      
      rtr_search_leaf(), rtr_insert_leaf(): Wrappers for
      rtr_search_to_nth_level().
      
      rtr_search(): Replaces rtr_pcur_open().
      
      rtr_cur_restore_position(): Remove an unused constant parameter.
      
      btr_pcur_open_on_user_rec(): Remove the constant parameter
      mode=PAGE_CUR_GE.
      
      btr_cur_latch_leaves(): Update a pre-existing mtr_t::m_memo entry
      for the current leaf page.
      
      row_ins_clust_index_entry_low(): Use a new
      mode=BTR_MODIFY_ROOT_AND_LEAF to gain access to the root page
      when mode!=BTR_MODIFY_TREE, to write the PAGE_ROOT_AUTO_INC.
      
      btr_cur_t::open_leaf(): Some clean-up.
      
      mtr_t::lock_register(): Register a page latch on a buffer-fixed block.
      
      BTR_SEARCH_TREE, BTR_CONT_SEARCH_TREE: Remove.
      
      BTR_CONT_MODIFY_TREE: Note that this is only used by
      rtr_search_to_nth_level().
      
      btr_pcur_optimistic_latch_leaves(): Replaces
      btr_cur_optimistic_latch_leaves().
      
      ibuf_delete_rec(): Acquire ibuf.index->lock.u_lock() in order
      to avoid a deadlock with ibuf_insert_low(BTR_MODIFY_PREV).
      
      Tested by: Matthias Leich
      f9cac8d2
    • Marko Mäkelä's avatar
      MDEV-30289: Implement small_vector for mtr_t::m_memo · 67dc8af2
      Marko Mäkelä authored
      To avoid heap memory allocation overhead for mtr_t::m_memo,
      we will allocate a small number of elements statically in
      mtr_t::m_memo::small. Only if that preallocated data is
      insufficient, we will invoke my_alloc() or my_realloc() for
      more storage. The implementation of the data structure is
      inspired by llvm::SmallVector.
      67dc8af2
    • Marko Mäkelä's avatar
  3. 18 Jan, 2023 4 commits
  4. 17 Jan, 2023 12 commits
  5. 16 Jan, 2023 1 commit
  6. 15 Jan, 2023 1 commit
  7. 14 Jan, 2023 2 commits
  8. 13 Jan, 2023 9 commits
    • Monty's avatar
      MDEV-30395 Wrong result with semijoin and Federated as outer table · 981a6b70
      Monty authored
      The problem was that federated engine does not support comparable rowids
      which was not taken into account by semijoin code.
      
      Fixed by checking that we don't use semijoin with tables that does not
      support comparable rowids.
      
      Other things:
      - Fixed some typos in the code comments
      981a6b70
    • Monty's avatar
      MDEV-30080 Wrong result with LEFT JOINs involving constant tables · 0595dd0f
      Monty authored
      The reason things fails in 10.5 and above is that test_quick_select()
      returns -1 (impossible range) for empty tables if there are any
      conditions attached.
      
      This didn't happen in 10.4 as the cost for a range was more than for
      a table scan with 0 rows and get_key_scan_params() did not create any
      range plans and thus did not mark the range as impossible.
      
      The code that checked the 'impossible range' conditions did not take
      into account all cases of LEFT JOIN usage.
      
      Adding an extra check if the table is used with an ON condition in case
      of 'impossible range' fixes the issue.
      0595dd0f
    • sjaakola's avatar
      10.4-MDEV-29684 Fixes for cluster wide write conflict resolving · 0ff7f33c
      sjaakola authored
      The rather recent thd_need_ordering_with() function does not take
      high priority transactions' order in consideration. Chaged this
      funtion to compare also transaction seqnos and favor earlier transaction.
      Reviewed-by: default avatarJan Lindström <jan.lindstrom@mariadb.com>
      0ff7f33c
    • sjaakola's avatar
      MDEV-29512 deadlock between commit monitor and THD::LOCK_thd_data mutex · 68cfcf9c
      sjaakola authored
      This commit contains only a mtr test for reproducing the issue in MDEV-29512
      The actual fix will be pushed in wsrep-lib repository
      
      The hanging in MDEV-29512 happens when binlog purging is attempted, and there is
      one local BF aborted transaction waiting for commit monitor.
      
      The test will launch two node cluster and enable binlogging with expire log days,
      to force binlog purging to happen.
      A local transaction is executed so that will become BF abort victim, and has advanced
      to replication stage waiting for commit monitor for final cleanup (to mark position in innodb)
      after that, applier is released to complete the BF abort and due to binlog configuration,
      starting the binlog purging. This is where the hanging would occur, if code is buggy
      Reviewed-by: default avatarJan Lindström <jan.lindstrom@mariadb.com>
      68cfcf9c
    • sjaakola's avatar
      MDEV-30317 Transaction savepoint may cause failure in galera replaying · cd97523d
      sjaakola authored
      Created mtr test for reproducing the crash
      
      Developed actual fix for the issue.
      Setting THD::system_thread_info.rpl_sql_info for replayer thread,
      same way as it is handled for appliers.
      
      Recorded test result, with the fix
      Reviewed-by: default avatarJan Lindström <jan.lindstrom@mariadb.com>
      cd97523d
    • sjaakola's avatar
      MDEV-29684 Fixes for cluster wide write conflict resolving · 66c05326
      sjaakola authored
      Cluster conflict victim's THD is marked with wsrep_aborter.
      THD::wsrep_aorter holds the thread ID of the hight priority tread,
      which is currently carrying out BF aborting for this victim.
      
      However, the BF abort operation is not always successful,
      and in such case the wsrep_aborter mark should be removed.
      In the old code, this wsrep_aborter resetting did not happen,
      and this could lead to a situation where the sticky wsrep_aborter
      mark prevents any further attempt to BF abort this transaction.
      
      This commit fixes this issue, and resets wsrep_aborter after
      unsuccesful BF abort attempt.
      Reviewed-by: default avatarJan Lindström <jan.lindstrom@mariadb.com>
      66c05326
    • Marko Mäkelä's avatar
      Merge 10.5 into 10.6 · 3386b309
      Marko Mäkelä authored
      3386b309
    • Marko Mäkelä's avatar
      Merge 10.4 into 10.5 · 73ecab3d
      Marko Mäkelä authored
      73ecab3d
    • Marko Mäkelä's avatar
      Merge 10.3 into 10.4 · 71e8e493
      Marko Mäkelä authored
      71e8e493
  9. 12 Jan, 2023 6 commits
  10. 11 Jan, 2023 1 commit