Commit graph

60583 commits

Author SHA1 Message Date
Dmitry Lenev
96344befd3 Fix for bug #50998 "Deadlock in MDL code during test
rqg_mdl_stability".

When start of statement's waiting on a metadata lock 
created more than one loop in waiters graph server might 
have entered deadlock condition.

The problem was that in the case described above MDL deadlock 
detector had to perform several searches for deadlock but
forgot to reset Deadlock_detection_context before performing 
new search. 
Failure to do so has broken assumption in code resposible for 
choosing victim that if Deadlock_detection_context::victim
is set we also have read lock on m_waiting_for_lock for this
context. As result this lock could have been unlocked more
times than it was acquired which corrupted rwlock's state
which led to server deadlock.

This fix ensures that such reset is done before each attempt
to find a deadlock.

mysql-test/r/mdl_sync.result:
  Added test for bug #50998 "Deadlock in MDL code during test
  rqg_mdl_stability" as well as coverage for the case when
  addition of statement waiting for metadata lock adds several
  loops in the waiters graph and therefore several searches
  for deadlock should be performed by MDL deadlock detector.
mysql-test/t/mdl_sync.test:
  Added test for bug #50998 "Deadlock in MDL code during test
  rqg_mdl_stability" as well as coverage for the case when
  addition of statement waiting for metadata lock adds several
  loops in the waiters graph and therefore several searches
  for deadlock should be performed by MDL deadlock detector.
sql/mdl.cc:
  Ensure that in cases when MDL deadlock detector had to
  perform several searches for deadlock because several loops
  in waiters graph are possible we reset
  Deadlock_detection_context before performing each search.
  Failure to do so has broken assumption in code resposible
  for choosing victim that if Deadlock_detection_context::victim
  is set we also have read lock on m_waiting_for_lock for this
  context. As result this lock could have been unlocked more
  times than it was acquired which corrupted rwlock's state
  (no one was able to acquire write lock on it anymore).
2010-02-10 18:46:03 +03:00
Alexander Nozdrin
7dc5666c6b Auto-merge from mysql-next-mr. 2010-02-09 13:40:08 +03:00
Alexander Nozdrin
6dd9375726 1. Disable ndb_condition_pushdown.test due to Bug 49746.
2. Update test result files.
2010-02-09 13:16:01 +03:00
Alexander Nozdrin
4f9a1f49c8 Manual merge from mysql-trunk.
Conflicts:
  - mysql-test/suite/ndb/r/ndb_dd_ddl.result
2010-02-09 13:14:29 +03:00
Alexander Nozdrin
06ce01bace Fix ndb_dd_ddl.test: drop created database after use. 2010-02-09 13:10:36 +03:00
Alexander Nozdrin
542b661de9 Auto-merge from mysql-trunk. 2010-02-09 13:09:20 +03:00
Joerg Bruehe
5d115bbe0c Upmerge "configure.in" text change from 5.1 to 5.5 ("trunk"),
fixing bug#50950.
2010-02-08 22:16:07 +01:00
Joerg Bruehe
ed75cda355 Upmerge "configure.in" text change from 5.0 to 5.1,
fixing bug#50950.
2010-02-08 21:40:17 +01:00
Dmitry Lenev
8018ec5adb Fix for bug #50913 "Deadlock between open_and_lock_tables_derived
and MDL".

Concurrent execution of a multi-DELETE statement and ALTER
TABLE statement which affected one of the tables used in
the multi-DELETE sometimes led to deadlock.
Similar deadlocks might have occured when one performed
INSERT/UPDATE/DELETE on a view and concurrently executed
ALTER TABLE for the view's underlying table, or when one
concurrently executed TRUNCATE TABLE for InnoDB table and
ALTER TABLE for the same table.

These deadlocks were caused by a discrepancy between types of
metadata and thr_lock.cc locks acquired by those statements.

What happened was that multi-DELETE/TRUNCATE/DML-through-the-
view statement in the first connection acquired SR lock on a
table, then ALTER TABLE would come in in the second connection
and acquire SNW metadata lock and TL_WRITE_ALLOW_READ
thr_lock.c lock and then would start waiting for the first
connection during lock upgrade. After that the statement in
the first connection would try to acquire TL_WRITE lock on
table and would start waiting for the second connection,
creating a deadlock.

This patch solves this problem by ensuring that we acquire
SW metadata lock in all cases in which we acquiring write
thr_lock.c lock. This guarantees that deadlocks like the
one described above won't occur since all lock conflicts
in such situation are resolved within MDL subsystem.

This patch also adds assert which should guarantee that
such situations won't arise in future.

mysql-test/r/lock_multi.result:
  Added main test for bug #50913 "Deadlock between
  open_and_lock_tables_derived and MDL".
mysql-test/r/mdl_sync.result:
  Added additional coverage for bug #50913 "Deadlock
  between open_and_lock_tables_derived and MDL".
mysql-test/t/lock_multi.test:
  Added main test for bug #50913 "Deadlock between
  open_and_lock_tables_derived and MDL".
mysql-test/t/mdl_sync.test:
  Added additional coverage for bug #50913 "Deadlock
  between open_and_lock_tables_derived and MDL".
sql/lock.cc:
  Added assert that enforces that when we are locking
  a non-temporary table we have an appropriate type of
  metadata lock on this table.
sql/mysql_priv.h:
  Added separate flag for open_tables() to be able specify that
  SH metadata locks on table to be open should be acquired.
  We can no longer use MYSQL_LOCK_IGNORE_FLUSH flag for this
  as in addition to use in I_S implementation it is also used
  for opening system tables. Since in the latter case we also
  acquire thr_lock.c locks using SH metadata lock in it instead
  of SR or SW locks may lead to deadlock.
sql/sql_base.cc:
  When opening tables don't interpret MYSQL_LOCK_IGNORE_FLUSH
  flag as request to acquire SH metadata locks. This flag is
  also used for opening system tables for which we also take
  thr_lock.c locks and thus proper metadata lock to take in
  this case is SR or SW lock (otherwise deadlocks can occur).
  In cases when SH lock is really required (e.g. when tables
  are open by I_S implementation) we rely on that newly
  introduced MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL flag is
  used.
sql/sql_delete.cc:
  mysql_truncate_by_delete():
    Adjust type of metadata lock to be requested after changing
    type of thr_lock.c lock for table list element from one
    which was set in parser to TL_WRITE.
    This removes discrepancy between types of these locks which
    allowed deadlocks to creep in.
sql/sql_handler.cc:
  When closing table which was open by HANDLER statement clear
  TABLE::open_by_handler flag. This allows to use this flag as
  a reliable indication that TABLE instance was open by HANDLER
  statement in assert which was added to mysql_lock_tables().
sql/sql_parse.cc:
  multi_delete_set_locks_and_link_aux_tables():
    Adjust type of metadata lock to be requested after changing
    type of thr_lock.c lock for table list element from one
    which was set in parser to TL_WRITE.
    This removes discrepancy between types of these locks which
    allowed deadlocks to creep in.
sql/sql_show.cc:
  Use newly introduced MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL
  flag in order to acquire SH metadata locks when opening tables
  in I_S implementation.
sql/sql_update.cc:
  Added comment explaining why in multi-update after deciding
  that we need weaker thr_lock.c lock on a table we don't
  downgrade metadata lock on it.
sql/sql_view.cc:
  When merging view into main statement adjust type of metadata
  lock to be requested after changing type of thr_lock.c lock
  for table. This removes discrepancy between types of these
  locks which allowed deadlocks to creep in.
2010-02-08 23:19:55 +03:00
Joerg Bruehe
72da6b3185 Bug#50950 Obsolete reference to www.mysql.com
in message printed at end of configure

New text for the success message of "configure".

configure.in:
  The message must be changed to drop the "www.mysql.com" URL.
2010-02-08 21:10:37 +01:00
Konstantin Osipov
4d4eed6514 Merge next-4284 -> next-4284-merge 2010-02-06 13:30:07 +03:00
Konstantin Osipov
a72f90bc43 Merge next-mr -> next-4284.
mysql-test/t/disabled.def:
  Restore disabled ssl tests: SSL certificates were updated.
  Disable sp_sync.test, the test case can't work in next-4284.
mysql-test/t/partition_innodb.test:
  Disable parsing of the test case for Bug#47343, 
  the test can not work in next-4284.
mysql-test/t/ps_ddl.test:
  Update results (CREATE TABLE IF NOT EXISTS takes
  into account existence of the temporary table).
2010-02-06 13:28:06 +03:00
Jon Olav Hauglid
95c2386148 Bug #50912 Assertion `ticket->m_type >= mdl_request->type'
failed on HANDLER + I_S

This assert was triggered when an I_S query tried to acquire a
metadata lock on a table which was already locked by a HANDLER
statement in the same connection.

First the HANDLER took a MDL_SHARED lock. Afterwards, the I_S query
requested a MDL_SHARED_HIGH_PRIO lock. The existing MDL_SHARED ticket
is found in find_ticket() since it satisfies 
ticket->has_stronger_or_equal_type(mdl_request->type) as MDL_SHARED
and MDL_SHARED_HIGH_PRIO have equal strengths, just different priority.

However, two asserts later check lock type strengths using relational
operators (>= and <=) rather than MDL_ticket::has_stronger_or_equal_type().
These asserts are triggered since MDL_SHARED >= MDL_SHARED_HIGH_PRIORITY
is false (mapped to 1 and 2 respectively).

This patch updates the asserts to use MDL_ticket::has_stronger_or_equal_type()
rather than relational operators to check lock type strength.

Test case added to include/handler.inc.
2010-02-06 10:44:03 +01:00
Konstantin Osipov
ba678eef7d Merge next-4284 -> next-4284-merge. 2010-02-05 20:41:00 +03:00
Konstantin Osipov
dad4caa9de next-mr -> next-4284 merge.
After merge fixes.
Adjust replication test cases.

mysql-test/suite/rpl/r/rpl_mixed_row_innodb.result:
  Update results with a new test.
mysql-test/suite/rpl/r/rpl_stm_loadfile.result:
  Add a warning, which I believe is an expected one.
mysql-test/suite/rpl/t/rpl_killed_ddl.test:
  Sort results to avoid test failurs under load.
mysql-test/suite/rpl_ndb/r/rpl_ndb_binlog_format_errors.result:
  Update results (next-4284 merge).
mysql-test/suite/rpl_ndb/t/rpl_ndb_binlog_format_errors.test:
  Adjust test output to the new table opening scheme: decide_logging_format() is now called in CREATE/DROP trigger.
2010-02-05 20:04:38 +03:00
Alexander Nozdrin
b38ef2b5f7 Auto-merge from mysql-trunk-merge. 2010-02-05 18:33:33 +03:00
Alexander Nozdrin
7e0d0dd040 Cherry-pick merge from mysql-5.1-bugteam.
Original revision:
------------------------------------------------------------
revision-id: kent.boortz@sun.com-20100204182709-dw1dwpglkd5qrehb
committer: Kent Boortz <kent.boortz@sun.com>
branch nick: mysql-5.1-bugteam
timestamp: Thu 2010-02-04 19:27:09 +0100
message:
  LT_INIT and LT_PREREQ was added in libtool 2.2 2008, a bit too
  recent, switched back to the older AC_PROG_LIBTOOL
------------------------------------------------------------
2010-02-05 18:31:06 +03:00
Alexander Nozdrin
d9c4234bc9 Auto-merge (empty) from mysql-trunk-merge. 2010-02-05 18:24:50 +03:00
Alexander Nozdrin
b6d1b25d50 Manual merge (empty) from mysql-5.1. 2010-02-05 18:14:01 +03:00
Alexander Nozdrin
23899d6d6b Auto-merge from mysql-next-mr. 2010-02-05 18:06:46 +03:00
Konstantin Osipov
f1d4c59da2 Add a suppression for use of functions unsafe in statement
format.

mysql-test/suite/rpl/t/rpl_view_multi.test:
  Add a suppression (fix a failing test).
2010-02-05 18:05:13 +03:00
Konstantin Osipov
a009a4e518 next-mr -> next-4284 merge:
Change the error code for ER_WARN_I_S_SKIPPED_TABLE, to not
upset the tests that rely on ER_SLAVE_CONVERSION_ERROR error
code = 1667.
Fix a merge bug with binlogging of CREATE TABLE (temporary tables).
2010-02-05 17:58:43 +03:00
Jon Olav Hauglid
82f4494125 Bug #50907 Assertion `hash_tables->table->next == __null' on
HANDLER OPEN

The problem was a too restrictive assert in the code for 
HANDLER ... OPEN and HANDLER ... READ that checked table->next
to verify that we didn't open views or merge tables.

This pointer is also used to link temporary tables together
(see thd->temporary_tables). In this case TABLE::next can be
set even if we're trying to open a single table.

This patch adjust the two asserts to also check for the presence
of temporary tables.

Test case added to handler_myisam.test.
2010-02-05 15:52:17 +01:00
Alexander Nozdrin
f53d591e9f Remove errmsg.txt and errmsg-cnv.sh. Use errmsg-utf8.txt instead. 2010-02-05 16:52:35 +03:00
Konstantin Osipov
7454283387 next-mr -> next-4284 merge:
fix a merge bug when write_bin_log called from mysql_routine_grant()
would chew up the error.
rpl_do_grant test would fail on assert that the diagnostics area is
empty.
2010-02-05 13:25:32 +03:00
Konstantin Osipov
a6f804228d A post-merge fix for next-mr -> next-4284 merge:
Make all mutexes and conditions of type mysql_mutex_t, mysql_cond_t,
since it's now the expectation of THD::awake().
2010-02-05 01:37:44 +03:00
Konstantin Osipov
e7b332ba83 Merge next-mr -> next-4284. 2010-02-05 01:08:08 +03:00
Konstantin Osipov
00dc9a6e70 Merge next-mr -> next-4284.
Cherry-pick a fix Bug#37148 from next-mr, to preserve
file ids of the added files, and ensure that all the necessary
changes have been pulled.

Since initially Bug#37148 was null-merged into 6.0,
the changeset that is now being cherry-picked was likewise
null merged into next-4284.

Now that Bug#37148 has been reapplied to 6.0, try to make
it work with next-4284. This is also necessary to be able
to pull other changes from 5.1-rep into next-4284.

To resolve the merge issues use this changeset applied
to 6.0:
revid:jperkin@sun.com-20091216103628-ylhqf7s6yegui2t9
revno: 3776.1.1
committer: He Zhenxing <zhenxing.he@sun.com>
branch nick: 6.0-codebase-bugfixing
timestamp: Thu 2009-12-17 17:02:50 +0800
message:
  Fix merge problem with Bug#37148
2010-02-04 23:15:47 +03:00
Konstantin Osipov
a9e22b5896 Merge next-mr -> next-4284-merge. 2010-02-04 20:34:15 +03:00
Dmitry Lenev
1edca1d7ef Small clean-up in CREATE TABLE LIKE implementation.
Removed local variables which became unused when we
have switched to new approach for CREATE TABLE LIKE
(i.e. abondoned .FRM file copying) and were causing
warnings during compilation.
2010-02-04 16:06:29 +03:00
unknown
88519d1c8f Raise version number after cloning 5.1.44 2010-02-04 12:23:33 +01:00
Georgi Kodinov
404b3be1ee merge 2010-02-04 12:14:44 +02:00
Georgi Kodinov
b8db15fc22 tree name change 2010-02-04 12:13:29 +02:00
Jon Olav Hauglid
a19377e0d7 Bug #50821 Deadlock between LOCK TABLES and ALTER TABLE
This was a deadlock between ALTER TABLE and another DML statement
(or LOCK TABLES ... READ). ALTER TABLE would wait trying to upgrade
its lock to MDL_EXCLUSIVE and the DML statement would wait trying
to acquire a TL_READ_NO_INSERT table level lock.

This could happen if one connection first acquired a MDL_SHARED_READ
lock on a table. In another connection ALTER TABLE is then started.
ALTER TABLE eventually blocks trying to upgrade to MDL_EXCLUSIVE,
but while holding a TL_WRITE_ALLOW_READ table level lock.

If the first connection then tries to acquire TL_READ_NO_INSERT,
it will block and we have a deadlock since neither connection can
proceed.

This patch fixes the problem by allowing TL_READ_NO_INSERT 
locks to be granted if another connection holds TL_WRITE_ALLOW_READ
on the same table. This will allow the DML statement to proceed
such that it eventually can release its MDL lock which in turn
makes ALTER TABLE able to proceed.

Note that TL_READ_NO_INSERT was already partially compatible with
TL_WRITE_ALLOW_READ as the latter would be granted if the former
lock was held. This patch just makes the opposite true as well.

Also note that since ALTER TABLE takes an upgradable MDL lock,
there will be no starvation of ALTER TABLE statements by
statements acquiring TL_READ or TL_READ_NO_INSERT.

Test case added to lock_sync.test.
2010-02-04 10:00:36 +01:00
Alexander Nozdrin
619037517f Fix test result file after manual merge. 2010-02-04 09:35:40 +03:00
Dmitry Lenev
f1f0228f84 Improve concurrency in metadata locking subsystem by
moving calculation of hash value when looking up
MDL_lock objects in MDL_map out of critical section.
2010-02-04 09:25:32 +03:00
Konstantin Osipov
4c94f28bec Merge next-4284 -> next-4284-merge 2010-02-04 01:06:07 +03:00
Alexander Nozdrin
fa03afee90 Manual merger from mysql-trunk-merge.
Conflicts:
  - configure.in
2010-02-04 00:52:48 +03:00
Konstantin Osipov
f30d17e078 Merge next-mr -> next-4284. 2010-02-04 00:48:40 +03:00
Alexander Nozdrin
ab73713265 Manual merge from mysql-trunk-merge.
Conflicts:
  - configure.in
2010-02-04 00:37:59 +03:00
Alexander Nozdrin
c746716869 Manual merge from mysql-trunk-merge.
Conflicts:
  - sql/sql_show.cc
2010-02-03 23:26:58 +03:00
Alexander Nozdrin
4a6457c8cb Manual merge from mysql-trunk-merge.
Conflicts:
  - sql/sql_select.cc
2010-02-03 23:15:57 +03:00
Dmitry Lenev
f677e97746 A follow-up for the patch which implemented new
type-of-operation-aware metadata locks and added a
wait-for graph based deadlock detector to the MDL
subsystem (this patch fixed bug #46272 "MySQL 5.4.4,
new MDL: unnecessary deadlock" and bug #37346
"innodb does not detect deadlock between update and
alter table").

Removed unused and redundant method.
2010-02-03 22:55:46 +03:00
Alexander Nozdrin
1a46ff873e Manual merge from mysql-5.1-bugteam.
Conflicts:
  - configure.in
  - mysql-test/include/setup_fake_relay_log.inc
  - sql/sql_select.cc
2010-02-03 20:22:58 +03:00
Alexander Nozdrin
f2360c9021 Temporarily null-merge patch for WL#5154 (deprecation WL) to next-mr. 2010-02-03 19:30:41 +03:00
Alexander Nozdrin
defe010c73 Manual merge from mysql-5.1-bugteam.
Conflicts:
  - sql/mysqld.cc
2010-02-03 19:28:40 +03:00
Alexander Nozdrin
1ab31553ca Manual merge from mysql-trunk-merge.
Conflicts:
  - mysql-test/t/bug46080.test
2010-02-03 19:21:17 +03:00
Georgi Kodinov
b51fa70a1f merge 2010-02-03 17:27:55 +02:00
Georgi Kodinov
d0ac5a75b3 merge 2010-02-03 17:25:29 +02:00
Konstantin Osipov
1397985d53 Merge next-4248 -> next-4284-merge 2010-02-03 18:12:39 +03:00