Commit graph

145 commits

Author SHA1 Message Date
Sergey Vojtovich
8774a02364 MDEV-11227 - mysqlimport -l doesn't issue UNLOCK TABLES
Implementation of MDEV-7660 introduced unwanted incompatible change:
modifications under LOCK TABLES with autocommit enabled are rolled back on
disconnect. Previously everything was committed, because LOCK TABLES didn't
adjust autocommit setting.

This patch restores original behavior by reverting some changes done in
MDEV-7660:
- sql/sql_parse.cc: do not reset autocommit on LOCK TABLES
- sql/sql_base.cc: do not set autocommit on UNLOCK TABLES
- test cases: main.lock_tables_lost_commit, main.partition_explicit_prune,
  rpl.rpl_switch_stm_row_mixed, tokudb.nested_txn_implicit_commit,
  tokudb_bugs.db806

But it makes InnoDB tables under LOCK TABLES ... READ [LOCAL] not protected
against DML. To restore protection some changes from WL#6671 were merged,
specifically MDL_SHARED_READ_ONLY and test cases.

WL#6671 merge highlights:
- Not all tests merged.
- In MySQL LOCK TABLES ... READ acquires MDL_SHARED_READ_ONLY for all engines,
  in MariaDB MDL_SHARED_READ is always acquired first and then upgraded to
  MDL_SHARED_READ_ONLY for InnoDB only.
- The above allows us to omit MDL_SHARED_WRITE_LOW_PRIO implementation in
  MariaDB, which is rather useless with InnoDB. In MySQL it is needed to
  preserve locking behavior between low priority writes and LOCK TABLES ... READ
  for non-InnoDB engines (covered by sys_vars.sql_low_priority_updates_func).
- Omitted HA_NO_READ_LOCAL_LOCK, we rely on lock_count() instead.
- Omitted "piglets": in MariaDB stream of DML against InnoDB table may lead to
  concurrent LOCK TABLES ... READ starvation.
- HANDLER ... OPEN acquires MDL_SHARED_READ instead of MDL_SHARED in MariaDB.
- Omitted SNRW->X MDL lock upgrade for IMPORT/DISCARD TABLESPAECE under LOCK
  TABLES.
- Omitted strong locks for views, triggers and SP under LOCK TABLES.
- Omitted IX schema lock for LOCK TABLES READ.
- Omitted deadlock weight juggling for LOCK TABLES.

Full WL#6671 merge status:
- innodb.innodb-lock: fully merged
- main.alter_table: not merged due to different HANDLER solution
- main.debug_sync: fully merged
- main.handler_innodb: not merged due to different HANDLER solution
- main.handler_myisam: not merged due to different HANDLER solution
- main.innodb_mysql_lock: fully merged
- main.insert_notembedded: fully merged
- main.lock: not merged (due to no strong locks for views)
- main.lock_multi: not merged
- main.lock_sync: fully merged (partially in MDEV-7660)
- main.mdl_sync: not merged
- main.partition_debug_sync: not merged due to different HANDLER solution
- main.status: fully merged
- main.view: fully merged
- perfschema.mdl_func: not merged (no such test in MariaDB)
- perfschema.table_aggregate_global_2u_2t: not merged (didn't fail in MariaDB)
- perfschema.table_aggregate_global_2u_3t: not merged (didn't fail in MariaDB)
- perfschema.table_aggregate_global_4u_2t: not merged (didn't fail in MariaDB)
- perfschema.table_aggregate_global_4u_3t: not merged (didn't fail in MariaDB)
- perfschema.table_aggregate_hist_2u_2t: not merged (didn't fail in MariaDB)
- perfschema.table_aggregate_hist_2u_3t: not merged (didn't fail in MariaDB)
- perfschema.table_aggregate_hist_4u_2t: not merged (didn't fail in MariaDB)
- perfschema.table_aggregate_hist_4u_3t: not merged (didn't fail in MariaDB)
- perfschema.table_aggregate_thread_2u_2t: not merged (didn't fail in MariaDB)
- perfschema.table_aggregate_thread_2u_3t: not merged (didn't fail in MariaDB)
- perfschema.table_aggregate_thread_4u_2t: not merged (didn't fail in MariaDB)
- perfschema.table_aggregate_thread_4u_3t: not merged (didn't fail in MariaDB)
- perfschema.table_lock_aggregate_global_2u_2t: not merged (didn't fail in MariaDB)
- perfschema.table_lock_aggregate_global_2u_3t: not merged (didn't fail in MariaDB)
- perfschema.table_lock_aggregate_global_4u_2t: not merged (didn't fail in MariaDB)
- perfschema.table_lock_aggregate_global_4u_3t: not merged (didn't fail in MariaDB)
- perfschema.table_lock_aggregate_hist_2u_2t: not merged (didn't fail in MariaDB)
- perfschema.table_lock_aggregate_hist_2u_3t: not merged (didn't fail in MariaDB)
- perfschema.table_lock_aggregate_hist_4u_2t: not merged (didn't fail in MariaDB)
- perfschema.table_lock_aggregate_hist_4u_3t: not merged (didn't fail in MariaDB)
- perfschema.table_lock_aggregate_thread_2u_2t: not merged (didn't fail in MariaDB)
- perfschema.table_lock_aggregate_thread_2u_3t: not merged (didn't fail in MariaDB)
- perfschema.table_lock_aggregate_thread_4u_2t: not merged (didn't fail in MariaDB)
- perfschema.table_lock_aggregate_thread_4u_3t: not merged (didn't fail in MariaDB)
- sys_vars.sql_low_priority_updates_func: not merged
- include/thr_rwlock.h: not merged, rw_pr_lock_assert_write_owner and
  rw_pr_lock_assert_not_write_owner are macros in MariaDB
- sql/handler.h: not merged (HA_NO_READ_LOCAL_LOCK)
- sql/mdl.cc: partially merged (MDL_SHARED_READ_ONLY only)
- sql/mdl.h: partially merged (MDL_SHARED_READ_ONLY only)
- sql/lock.cc: fully merged
- sql/sp_head.cc: not merged
- sql/sp_head.h: not merged
- sql/sql_base.cc: partially merged (MDL_SHARED_READ_ONLY only)
- sql/sql_base.h: not merged
- sql/sql_class.cc: fully merged
- sql/sql_class.h: fully merged
- sql/sql_handler.cc: merged partially (different solution in MariaDB)
- sql/sql_parse.cc: partially merged, mostly omitted low priority write part
- sql/sql_reload.cc: not merged comment change
- sql/sql_table.cc: not merged SNRW->X upgrade for IMPORT/DISCARD TABLESPACE
- sql/sql_view.cc: not merged
- sql/sql_yacc.yy: not merged (MDL_SHARED_WRITE_LOW_PRIO, MDL_SHARED_READ_ONLY)
- sql/table.cc: not merged (MDL_SHARED_WRITE_LOW_PRIO)
- sql/table.h: not merged (MDL_SHARED_WRITE_LOW_PRIO)
- sql/trigger.cc: not merged
- storage/innobase/handler/ha_innodb.cc: merged store_lock()/lock_count()
  changes (in MDEV-7660), didn't merge HA_NO_READ_LOCAL_LOCK
- storage/innobase/handler/ha_innodb.h: fully merged in MDEV-7660
- storage/myisammrg/ha_myisammrg.cc: not merged comment change
- storage/perfschema/table_helper.cc: not merged (no MDL support in MariaDB PFS)
- unittest/gunit/mdl-t.cc: not merged
- unittest/gunit/mdl_sync-t.cc: not merged

MariaDB specific changes:
- handler.heap: different HANDLER solution, MDEV-7660
- handler.innodb: different HANDLER solution, MDEV-7660
- handler.interface: different HANDLER solution, MDEV-7660
- handler.myisam: different HANDLER solution, MDEV-7660
- main.mdl_sync: MDEV-7660 specific changes
- main.partition_debug_sync: removed test due to different HANDLER solution,
  MDEV-7660
- main.truncate_coverage: removed test due to different HANDLER solution,
  MDEV-7660
- mysql-test/include/mtr_warnings.sql: additional cleanup, MDEV-7660
- mysql-test/lib/v1/mtr_report.pl: additional cleanup, MDEV-7660
- plugin/metadata_lock_info/metadata_lock_info.cc: not in MySQL
- sql/sql_handler.cc: MariaDB specific fix for mysql_ha_read(), MDEV-7660
2016-12-21 13:18:45 +04:00
Sergei Golubchik
06b7fce9f2 Merge branch '10.1' into 10.2 2016-09-09 08:33:08 +02:00
Sergei Golubchik
6b1863b830 Merge branch '10.0' into 10.1 2016-08-25 12:40:09 +02:00
Monty
b51109693e MDEV-10630 rpl.rpl_mdev6020 fails in buildbot with timeout
The issue was that when running with valgrind the wait for master_pos_Wait()
was not long enough.

This patch also fixes two other failures that could affect rpl_mdev6020:
- check_if_conflicting_replication_locks() didn't properly check domains
- 'did_mark_start_commit' was after signals to other threads was sent which could
  get the variable read too early.
2016-08-22 10:16:00 +03:00
Monty
98e36b2999 With parallel replication we have had a couple of bugs where DDL's
(like DROP TABLE) has been scheduled before conflicting DDL's (like INSERT)
are commited.

What makes these bugs hard to detect is that in most cases any wrong
schduling are caught by MDL locks. It's only when there are timing issues
that the bugs (usually deadlocks) are noticed.

This patch adds a DBUG_ASSERT() that detects, in parallel replication,
if a DDL is scheduled before any depending DML'S are commited.
It does this be checking if there are any conflicting replication locks
when the DDL is about to wait for getting it's MDL lock.

I also did some minor code cleanups in sql_base.cc to make this code
similar to other related code.
2016-08-12 20:02:23 +03:00
Nirbhay Choubey
355bf4fbb5 Cleanup around wsrep mdl exception. 2016-07-30 14:36:41 -04:00
Monty
4dc5075860 Fixed compiler warnings and test failures found by buildbot
Fixed ccfilter to detect errors where the column is included in the error message
2016-06-24 02:25:14 +03:00
Sergey Vojtovich
82a96926a7 MDEV-9728 - Hard crash in metadata_lock_info
metadata_lock_info plugin called MDL_context::find_ticket() to obtain lock
duration, which in turn iterates foreign thread private lists. These lists
can be updated by owner thread without protection.

Fixed by iterating threads (instead of MDL locks and tickets) and obtaining
data through APC.

Also fixed mdl_iterate_lock() to initialize iterator under prlock protection.
2016-06-21 17:04:57 +04:00
Nirbhay Choubey
cceec7858f Merge branch '10.0-galera' into bb-10.1-serg 2016-02-24 01:21:40 -05:00
sjaakola
32df0b1aac refs codership/mysql-wsrep#233
- avoiding the race condition, by not grabbing thd->LOCK_wsrep_thd for
  accessing thd->wsrep_exec_mode. The caller is same thread and exec mode
  can only be changed by self.
2016-02-23 00:22:04 -05:00
sjaakola
18f160d954 refs codership/mysql-wsrep#233
- added dbug sync points for further mtr test for this issue
2016-02-23 00:13:12 -05:00
Sergei Golubchik
2fc3dc393d Merge branch '10.1' into bb-10.1-serg 2015-11-20 09:31:13 +01:00
Monty
1e156e1436 Fixed compile warnings on Solaris 2015-11-20 10:00:06 +02:00
Sergei Golubchik
7f19330c59 Merge branch 'github/10.0-galera' into 10.1 2015-11-19 17:48:36 +01:00
Philip Stoev
43b2a451fe refs codership/mysql-wsrep#202 Added schema info into wsrep messages
Added schema info to wsrep messages above debug level.
2015-10-19 01:56:04 -07:00
sjaakola
2106fed865 Refs codership/mysql-wsrep#113
- changed BF thread's MDL wait to never timeout
- all explicit locks are now honored by BF threads
2015-09-09 21:37:17 -04:00
sjaakola
63c5bee535 Refs codership/mysql-wsrep#113 - Extended the protection of local FLUSH
sessions to cover all exclusive MDL locks
2015-09-09 21:31:16 -04:00
Nirbhay Choubey
dced5146bd Merge branch '10.0-galera' into 10.1 2015-07-14 16:05:29 -04:00
Monty
7332af49e4 - Renaming variables so that they don't shadow others (After this patch one can compile with -Wshadow and get much fewer warnings)
- Changed ER(ER_...) to ER_THD(thd, ER_...) when thd was known or if there was many calls to current_thd in the same function.
- Changed ER(ER_..) to ER_THD_OR_DEFAULT(current_thd, ER...) in some places where current_thd is not necessary defined.
- Removing calls to current_thd when we have access to thd

Part of this is optimization (not calling current_thd when not needed),
but part is bug fixing for error condition when current_thd is not defined
(For example on startup and end of mysqld)

Notable renames done as otherwise a lot of functions would have to be changed:
- In JOIN structure renamed:
   examined_rows -> join_examined_rows
   record_count -> join_record_count
- In Field, renamed new_field() to make_new_field()

Other things:
- Added DBUG_ASSERT(thd == tmp_thd) in Item_singlerow_subselect() just to be safe.
- Removed old 'tab' prefix in JOIN_TAB::save_explain_data() and use members directly
- Added 'thd' as argument to a few functions to avoid calling current_thd.
2015-07-06 20:24:14 +03:00
Nirbhay Choubey
70714d3597 Merge branch '5.5-galera' into 10.0-galera 2015-06-23 16:46:12 -04:00
Nirbhay Choubey
fc716dc5a5 MDEV-8260 : Issues related to concurrent CTAS
* Wait for aborted thd (victim) to release MDL locks
* Skip aborting an already aborted thd
* Defer setting OK status in case of CTAS
* Minor cosmetic changes
* Added a test case
2015-06-19 19:25:15 -04:00
Sergey Vojtovich
8f603bcbca MDEV-7952 - clock_gettime() takes 0.24% in OLTP RO
Initialize abs_timeout when it is about to be used. This saves one my_hrtime()
call on hot path (when we acquire MDL lock without waiting).

When filling I_S.PROCESSLIST use THD::start_utime/THD::utime_after_query instead
of THD::start_time. This allows us to save 2 clock_gettime() calls.

Overhead change:
__clock_gettime   0.13% -> 0.11% (122 -> 76 calls per OLTP RO transaction)
my_interval_timer 0.07% -> 0.06%
my_hrtime         0.04% -> 0.01%
2015-06-19 15:06:34 +04:00
Sergey Vojtovich
ff1e0821d1 MDEV-8073 - Build error in sql/mdl.cc on OS X 10.10
C++03 seem to require default constructor for const objects even though they're
fully initialized. There is defect report for this:
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#253

Apparently some compilers (e.g. gcc) addressed this defect report, while some
(e.g. clang) did not.

Added empty default constructor to MDL_scoped_lock and MDL_object_lock classes.

Also replaced lf_hash_search_using_hash_value() with lf_hash_search(). The
latter will call mdl_key->hash_value() anyway.
2015-04-30 12:36:39 +04:00
Sergey Vojtovich
5c6aa4dea0 MDEV-6089 - MySQL WL#7305 "Improve MDL scalability by using lock-free hash"
Replaced hash with lock-free hash.
2015-03-04 13:34:53 +04:00
Sergey Vojtovich
f5bd1d0126 MDEV-6089 - MySQL WL#7305 "Improve MDL scalability by using lock-free hash"
Simplified MDL_object_lock and MDL_scoped_lock dichotomy so that they can be
stored in LF_HASH. This was done by moving out their differences to a
MDL_lock_strategy structure which is referenced from the MDL_lock object by
pointer.
2015-03-04 13:34:53 +04:00
Sergey Vojtovich
f475a7f949 MDEV-6089 - MySQL WL#7305 "Improve MDL scalability by using lock-free hash"
Replaced m_ref_usage, m_ref_release, m_is_destroyed and m_version with single
m_state, which is updated atomically. Needed to get rid of MDL_map::m_mutex.
2015-03-04 13:34:52 +04:00
Sergey Vojtovich
ecd3ff9f24 MDEV-6089 - MySQL WL#7305 "Improve MDL scalability by using lock-free hash"
Removed MDL map partitions. Won't be needed when this MDEV is implemented.
2015-03-04 13:34:52 +04:00
Sergey Vojtovich
903160ef59 MDEV-6089 - MySQL WL#7305 "Improve MDL scalability by using lock-free hash"
Removed MDL objects cache. Won't be needed when this MDEV is implemented.
2015-03-04 13:34:52 +04:00
Sergei Golubchik
4b21cd21fe Merge branch '10.0' into merge-wip 2015-01-31 21:48:47 +01:00
Nirbhay Choubey
7cda4bee0e maria-10.0.16 merge
bzr merge -r4588 maria/10.0
2015-01-26 22:54:27 -05:00
Sergei Golubchik
73ebabd2ee MDEV-7299 Assertion `m_status == DA_ERROR || m_status == DA_OK' fails on concurrent execution of DDL, queries from I_S, and KILL QUERY
Fix MDL to report an error when a wait was killed, but preserve
the old documented behavior of GET_LOCK() where killing it is not an error.

Also remove race conditions in main.create_or_replace test
2015-01-19 14:19:14 +01:00
Sergei Golubchik
2ae7541bcf cleanup: s/const CHARSET_INFO/CHARSET_INFO/
as CHARSET_INFO is already const, using const on it
is redundant and results in compiler warnings (on Windows)
2014-12-04 10:41:51 +01:00
Nirbhay Choubey
3e792e6cbc MDEV-4018 : Feature Request: microseconds in GET_LOCK()
Updated MDL_context's lock methods to accept double precision
lock_wait_timeout.
2014-11-30 01:05:34 -05:00
Sergei Golubchik
7aabc2ded2 fixing embedded: WaaS. Wsrep as a Service. 2014-10-01 23:48:34 +02:00
Sergei Golubchik
3620910eea cleanup: galera merge, simple changes 2014-10-01 23:38:27 +02:00
Jan Lindström
df4dd593f2 MDEV-6247: Merge 10.0-galera to 10.1.
Merged lp:maria/maria-10.0-galera up to revision 3879.

Added a new functions to handler API to forcefully abort_transaction,
producing fake_trx_id, get_checkpoint and set_checkpoint for XA. These
were added for future possiblity to add more storage engines that
could use galera replication.
2014-08-26 15:43:46 +03:00
Nirbhay Choubey
086af8367e bzr merge -r4209 maria/10.0. 2014-05-21 11:09:55 -04:00
Sergey Vojtovich
b123249010 MDEV-5792 - Deadlock between SELECTs from METADATA_LOCK_INFO and another
I_S table

mdl_iterate() helper function (which is used by the plugin to iterate mdl
locks) acquired mutexes in reverse order.

Fixed by iterating MDL locks in two stages:
1. Iterate locks hash under the protection of hash mutex, store all
   lock pointers in a thread local array and increment reference counter
   for the lock.
2. Iterate local array without protection of hash mutex, handle destroyed
   locks.

It somewhat echoes hack in MDL_map_partition::move_from_hash_to_lock_mutex.
2014-04-23 11:34:06 +04:00
Nirbhay Choubey
4213263101 Merging mariadb-10.0.10.
* bzr merge -rtag:mariadb-10.0.10 maria/10.0.
2014-04-08 10:36:34 -04:00
Nirbhay Choubey
02ba2bfdb4 Merging revision from codership-mysql/5.5 (r3928..3968) and
codership-mysql/5.6 (r4021..4065).
- Also contains fixes for some build failures.
2014-03-27 16:26:00 -04:00
Nirbhay Choubey
90e4f7f9d3 * bzr merge -rtag:mariadb-10.0.9 maria/10.0
* Fix for post-merge build failures.
2014-03-26 14:27:24 -04:00
Nirbhay Choubey
b5871a51e9 * bzr merge -r4027..4061 codership/5.6
* Merged Innodb changes to xtradb
2014-03-26 11:12:38 -04:00
Nirbhay Choubey
3088d52c20 bzr merge -r3933..3945 codership/5.5 (Non-InnoDB changes only). 2014-03-25 14:42:15 -04:00
Sergey Vojtovich
e4fde57712 MDEV-5864 - Reduce usage of LOCK_open: TABLE_SHARE::tdc.free_tables
Let TABLE_SHARE::tdc.free_tables, TABLE_SHARE::tdc.all_tables,
TABLE_SHARE::tdc.flushed and corresponding invariants be protected by
per-share TABLE_SHARE::tdc.LOCK_table_share instead of global LOCK_open.
2014-03-20 11:11:13 +04:00
Sergey Vojtovich
b95c8ce530 MDEV-5675 - Performance: my_hash_sort_bin is called too often
Reduced number of my_hash_sort_bin() calls from 4 to 1 per query.
Reduced number of memory accesses done by my_hash_sort_bin().

Details:
- let MDL subsystem use pre-calculated hash value for hash
  inserts and deletes
- let table cache use pre-calculated MDL hash value
- MDL namespace is excluded from hash value calculation, so that
  hash value can be used by table cache as is
- hash value for MDL is calculated as resulting hash value + MDL
  namespace
- extended hash implementation to accept user defined hash function
2014-03-06 16:19:12 +04:00
Nirbhay Choubey
4cb029b38b * Merged the missing revision 3934 from
codership-mysql/5.5 (missed in the last merge).
* Merged changes from Innodb to xtradb.
* Updated WSREP_PATCH_REVNO
2014-02-05 00:28:11 -05:00
Jan Lindström
d43afb8828 Merge MariaDB-10.0.7 revision 3961. 2014-01-25 11:02:49 +02:00
Nirbhay Choubey
9d5c3731be Fixes for some compiler warnings. 2014-01-09 23:22:10 -05:00
Nirbhay Choubey
31eaa90a6e Merging revision 3839..3932 from codership-mysql/5.5. 2014-01-09 14:54:57 -05:00
Kentoku SHIBA
3771e14ea9 add metadata_lock_info 2013-12-11 00:31:04 +09:00