1. 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
  2. 24 Jan, 2018 7 commits
  3. 23 Jan, 2018 4 commits
  4. 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
  5. 21 Jan, 2018 3 commits
  6. 20 Jan, 2018 15 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
    • Sergey Vojtovich's avatar
      MDEV-14756 - Remove trx_sys_t::rw_trx_list · 02270b44
      Sergey Vojtovich authored
      Let lock_validate_table_locks(), lock_rec_other_trx_holds_expl(),
      lock_table_locks_lookup(), trx_recover_for_mysql(), trx_get_trx_by_xid(),
      trx_roll_must_shutdown(), fetch_data_into_cache() iterate rw_trx_hash
      instead of rw_trx_list.
      02270b44
    • Sergey Vojtovich's avatar
      MDEV-14756 - Remove trx_sys_t::rw_trx_list · d8c0caad
      Sergey Vojtovich authored
      Removed trx_sys_validate_trx_list(): with rw_trx_hash elements are not
      required to be ordered by transaction id. Transaction state is now guarded
      by asserts in rw_trx_hash_t.
      d8c0caad
    • Sergey Vojtovich's avatar
      MDEV-14756 - Remove trx_sys_t::rw_trx_list · 900b0790
      Sergey Vojtovich authored
      Removed trx_sys_t::n_prepared_recovered_trx: never used.
      
      Removed trx_sys_t::n_prepared_trx: used only at shutdown, we can perfectly
      get this value from rw_trx_hash.
      900b0790
    • Sergey Vojtovich's avatar
      MDEV-14756 - Remove trx_sys_t::rw_trx_list · a0b385ea
      Sergey Vojtovich authored
      Determine minimum transaction id by iterating rw_trx_hash, not rw_trx_list.
      
      It is more expensive than previous implementation since it does linear
      search, especially if there're many concurrent transactions running. But in
      such case mutex is much bigger evil. And since it doesn't require
      trx_sys->mutex protection it scales better.
      
      For low concurrency performance difference is neglible.
      a0b385ea
    • Sergey Vojtovich's avatar
      MDEV-14756 - Remove trx_sys_t::rw_trx_list · 868c77df
      Sergey Vojtovich authored
      Replaced UT_LIST_GET_LEN(trx_sys->rw_trx_list) with
      trx_sys->rw_trx_hash.size().
      Moved freeing of trx objects at shutdown to rw_trx_hash destructor.
      Small clean-up in trx_rollback_recovered().
      868c77df