1. 26 Jan, 2018 5 commits
    • Sergey Vojtovich's avatar
      MDEV-15059 - Misc small InnoDB scalability fixes · 55277e88
      Sergey Vojtovich authored
      Form better trx_sys API.
      55277e88
    • Sergey Vojtovich's avatar
      MDEV-15059 - Misc small InnoDB scalability fixes · 064bd780
      Sergey Vojtovich authored
      When cloning oldest view, don't copy ReadView::m_creator_trx_id.
      It means that the owner thread is now allowed to access this member
      without trx_sys.mutex protection.
      
      To achieve this we have to keep ReadView::m_creator_trx_id in
      ReadView::m_ids. This is required to not let purge thread process
      records owned by transaction associated with oldest view.
      
      It is only required if trsanction entered read-write mode before it's
      view was created.
      
      If transaction entered read-write mode after it's view was created
      (trx_set_rw_mode()), purge thread won't be allowed to touch it because
      m_low_limit_id >= m_creator_trx_id holds. Thus we don't have to add
      this transaction id to ReadView::m_ids.
      
      Cleanups:
      
      ReadView::ids_t: don't seem to make any sense, just complicate matters.
      
      ReadView::copy_trx_ids(): doesn't make sense anymore, integrated into
      caller.
      
      ReadView::copy_complete(): not needed anymore.
      
      ReadView copy constructores: don't seem to make any sense.
      
      trx_purge_truncate_history(): removed view argument, access
      purge_sys->view directly instead.
      064bd780
    • Sergey Vojtovich's avatar
      MDEV-15059 - Misc small InnoDB scalability fixes · 04996939
      Sergey Vojtovich authored
      Moved lock_rec_lock_slow() inside lock_rec_lock().
      04996939
    • Sergey Vojtovich's avatar
      MDEV-15059 - Misc small InnoDB scalability fixes · 8389b45b
      Sergey Vojtovich authored
      Moved mutex locking inside lock_rec_lock().
      Moved monitor increment out of mutex.
      Moved assertions that don't require protection out of mutex.
      Removed duplicate assertions.
      Moved duplicate debug injections into lock_rec_lock().
      Let monitor updates use relaxed memory order.
      Return directly without maintaining variables in lock_rec_lock_slow().
      Moved lock_rec_lock_fast() body into lock_rec_lock(): saves at least one
      trx_mutex_enter(), one switch() plus some code was moved out of mutex.
      8389b45b
    • Sergey Vojtovich's avatar
      MDEV-14482 - Cache line contention on ut_rnd_ulint_counter() · ce047900
      Sergey Vojtovich authored
      InnoDB RNG maintains global state, causing otherwise unnecessary bus
      traffic. Even worse this is cross-mutex traffic. That is different
      mutexes suffer from contention.
      
      Fixed delay of 4 was verified to give best throughput by OLTP update
      index and read-write benchmarks on Intel Broadwell (2/20/40) and
      ARM (1/46/46).
      ce047900
  2. 25 Jan, 2018 2 commits
    • Marko Mäkelä's avatar
      MDEV-15061 TRUNCATE must honor InnoDB table locks · 92d233a5
      Marko Mäkelä authored
      Traditionally, DROP TABLE and TRUNCATE TABLE discarded any locks that
      may have been held on the table. This feels like an ACID violation.
      Probably most occurrences of it were prevented by meta-data locks (MDL)
      which were introduced in MySQL 5.5.
      
      dict_table_t::n_foreign_key_checks_running: Reduce the number of
      non-debug checks.
      
      lock_remove_all_on_table(), lock_remove_all_on_table_for_trx(): Remove.
      
      ha_innobase::truncate(): Acquire an exclusive InnoDB table lock
      before proceeding. DROP TABLE and DISCARD/IMPORT were already doing
      this.
      
      row_truncate_table_for_mysql(): Convert the already started transaction
      into a dictionary operation, and do not invoke lock_remove_all_on_table().
      
      row_mysql_table_id_reassign(): Do not call lock_remove_all_on_table().
      This function is only used in ALTER TABLE...DISCARD/IMPORT TABLESPACE,
      which is already holding an exclusive InnoDB table lock.
      
      TODO: Make n_foreign_key_checks running a debug-only variable.
      This would require two fixes:
      (1) DROP TABLE: Exclusively lock the table beforehand, to prevent
      the possibility of concurrently running foreign key checks (which
      would acquire a table IS lock and then record S locks).
      (2) RENAME TABLE: Find out if n_foreign_key_checks_running>0 actually
      constitutes a potential problem.
      92d233a5
    • Galina Shalygina's avatar
      Bug fix · f1ff69cf
      Galina Shalygina authored
      Wrong conversion
      f1ff69cf
  3. 24 Jan, 2018 7 commits
  4. 23 Jan, 2018 4 commits
  5. 22 Jan, 2018 9 commits
    • Marko Mäkelä's avatar
      MDEV-12173 "[Warning] Trying to access missing tablespace" · 29eeb527
      Marko Mäkelä authored
      ibuf_merge_or_delete_for_page(): Invoke fil_space_acquire_silent()
      instead of fil_space_acquire() in order to avoid displaying
      a useless message.
      
      We know perfectly well that a tablespace can be dropped while a
      change buffer merge is pending, because change buffer merges skip
      any transactional locks.
      29eeb527
    • Marko Mäkelä's avatar
      89ae5d7f
    • Marko Mäkelä's avatar
      30f1d2f6
    • Marko Mäkelä's avatar
      MDEV-15029 XA COMMIT and XA ROLLBACK operate on freed transaction object · d04e1d4b
      Marko Mäkelä authored
      innobase_commit_by_xid(), innobase_rollback_by_xid(): Decrement
      the reference count before freeing the transaction object to the pool.
      Failure to do so might corrupt the transaction bookkeeping
      if trx_create_low() returns the same object to another thread
      before we are done with it.
      
      trx_sys_close(): Detach the recovered XA PREPARE transactions from
      trx_sys->rw_trx_list before freeing them.
      d04e1d4b
    • Sergey Vojtovich's avatar
      Simplified away ReadView::complete() · 8e1adff9
      Sergey Vojtovich authored
      It was supposed to be called out of mutex, but nevertheless was called
      under trx_sys.mutex for normal threads adding one extra condtion in
      critical section.
      8e1adff9
    • Sergey Vojtovich's avatar
      MDEV-15019 - InnoDB: store ReadView on trx · 4dc30f3c
      Sergey Vojtovich authored
      This will allow us to reduce critical section protected by
      trx_sys.mutex:
      - no need to maintain global m_free list
      - eliminate if (trx->read_view == NULL) condition.
      
      On x86_64 sizeof(Readview) is 144 mostly due to padding, sizeof(trx_t)
      with ReadView is 1200.
      
      Also don't close ReadView for read-write transactions, just mark it
      closed similarly to read-only.
      
      Clean-up: removed n_prepared_recovered_trx and n_prepared_trx, which
      accidentally re-appeared after some rebase.
      4dc30f3c
    • Sergei Petrunia's avatar
      MDEV-13352: Server crashes in st_join_table::remove_duplicates · 9b4dfdaa
      Sergei Petrunia authored
      join_tab->distinct=true means "Before doing record read with this
      join_tab, call join_tab->remove_duplicates() to eliminate duplicates".
      remove_duplicates() assumes that
      - there is a temporary table $T with rows that are to be de-duplicated
      - there is a previous join_tab (e.g. with join_tab->fields) which was
      used to populate the temp.table $T.
      
      When the query has "Impossible WHERE" and window function, then the above
      conditions are not met (but we still might need a window function
      computation step when the query has implicit grouping).
      
      The fix is to not add remove_duplicates step if the select execution is
      degenerate (and we'll have at most one row in the output anyway).
      9b4dfdaa
    • Marko Mäkelä's avatar
      Merge 10.2 into bb-10.2-ext · c425dcd8
      Marko Mäkelä authored
      c425dcd8
    • Marko Mäkelä's avatar
      MDEV-14941 Timeouts on persistent statistics tables caused by MDEV-14511 · 4f8555f1
      Marko Mäkelä authored
      MDEV-14511 tried to avoid some consistency problems related to InnoDB
      persistent statistics. The persistent statistics are being written by
      an InnoDB internal SQL interpreter that requires the InnoDB data dictionary
      cache to be locked.
      
      Before MDEV-14511, the statistics were written during DDL in separate
      transactions, which could unnecessarily reduce performance (each commit
      would require a redo log flush) and break atomicity, because the statistics
      would be updated separately from the dictionary transaction.
      
      However, because it is unacceptable to hold the InnoDB data dictionary
      cache locked while suspending the execution for waiting for a
      transactional lock (in the mysql.innodb_index_stats or
      mysql.innodb_table_stats tables) to be released, any lock conflict
      was immediately be reported as "lock wait timeout".
      
      To fix MDEV-14941, an attempt to reduce these lock conflicts by acquiring
      transactional locks on the user tables in both the statistics and DDL
      operations was made, but it would still not entirely prevent lock conflicts
      on the mysql.innodb_index_stats and mysql.innodb_table_stats tables.
      
      Fixing the remaining problems would require a change that is too intrusive
      for a GA release series, such as MariaDB 10.2.
      
      Thefefore, we revert the change MDEV-14511. To silence the
      MDEV-13201 assertion, we use the pre-existing flag trx_t::internal.
      4f8555f1
  6. 21 Jan, 2018 3 commits
  7. 20 Jan, 2018 10 commits
    • Sergey Vojtovich's avatar
      Get rid of trx->read_view pointer juggling · ec32c050
      Sergey Vojtovich authored
      trx->read_view|= 1 was done in a silly attempt to fix race condition
      where trx->read_view was closed without trx_sys.mutex lock by read-only
      trasnactions.
      
      This just made the problem less likely to happen. In fact there was race
      condition in const version of trx_get_read_view(): pointer may change to
      garbage any moment after MVCC::is_view_active(trx->read_view) check and
      before this function returns.
      
      This patch doesn't fix this race condition, but rather makes it's
      consequences less destructive.
      ec32c050
    • Sergey Vojtovich's avatar
      MVCC simplifications · 95070bf9
      Sergey Vojtovich authored
      Simplified away MVCC::get_oldest_view()
      Simplified away MVCC::get_view()
      Removed unused MVCC::view_release()
      95070bf9
    • Sergey Vojtovich's avatar
      Misc trx_sys scalability fixes · 90bf5567
      Sergey Vojtovich authored
      trx_erase_lists(): trx->read_view is owned by current thread and thus
      doesn't need trx_sys.mutex protection for reading it's value. Move
      trx->read_view check out of mutex
      
      trx_start_low(): moved assertion out of mutex.
      
      Call ReadView::creator_trx_id() directly: allows to inline this one-line
      method.
      90bf5567
    • Sergey Vojtovich's avatar
      Removed purge_trx_id_age and purge_view_trx_id_age · 64048baf
      Sergey Vojtovich authored
      These were unused status variables available in debug builds only.
      Also removed trx_sys.rw_max_trx_id: not used anymore.
      64048baf
    • Sergey Vojtovich's avatar
      Allocate trx_sys.mvcc at link time · db5bb785
      Sergey Vojtovich authored
      trx_sys.mvcc was allocated dynamically for no good reason.
      db5bb785
    • Marko Mäkelä's avatar
      Replace trx_sys_t* trx_sys with trx_sys_t trx_sys · f8882cce
      Marko Mäkelä authored
      There is only one transaction system object in InnoDB.
      Allocate the storage for it at link time, not at runtime.
      
      lock_rec_fetch_page(): Use the correct fetch mode BUF_GET.
      Pages may never be deallocated from a tablespace while
      record locks are pointing to them.
      f8882cce
    • Sergey Vojtovich's avatar
      MDEV-14756 - Remove trx_sys_t::rw_trx_list · 70782033
      Sergey Vojtovich authored
      Use atomic operations when accessing trx_sys_t::max_trx_id. We can't yet
      move trx_sys_t::get_new_trx_id() out of mutex because it must be updated
      atomically along with trx_sys_t::rw_trx_ids.
      70782033
    • Sergey Vojtovich's avatar
      MDEV-14756 - Remove trx_sys_t::rw_trx_list · c6d2842d
      Sergey Vojtovich authored
      Remove rw_trx_list.
      c6d2842d
    • Sergey Vojtovich's avatar
      MDEV-14756 - Remove trx_sys_t::rw_trx_list · a447980f
      Sergey Vojtovich authored
      Let lock_print_info_all_transactions() iterate rw_trx_hash instead of
      rw_trx_list.
      
      When printing info of locks for transactions, InnoDB monitor doesn't
      attempt to read relevant page from disk anymore. The code was prone
      to race conditions.
      
      Note that TrxListIterator didn't work as advertised: it iterated
      rw_trx_list only.
      a447980f
    • Sergey Vojtovich's avatar
      MDEV-14756 - Remove trx_sys_t::rw_trx_list · 886af392
      Sergey Vojtovich authored
      Let trx_rollback_recovered() iterate rw_trx_hash instead of rw_trx_list.
      886af392