3159 Luis Soares 2010-09-16 [merge]
Automerge from mysql-next-mr into mysql-next-mr-wl5092.
modified:
client/CMakeLists.txt
include/CMakeLists.txt
include/Makefile.am
mysql-test/r/sp-destruct.result
mysql-test/t/sp-destruct.test
scripts/CMakeLists.txt
scripts/make_win_bin_dist
sql/CMakeLists.txt
sql/mdl.cc
sql/mdl.h
sql/sp.cc
sql/sql_base.cc
sql/sql_base.h
sql/table.cc
3158 Luis Soares 2010-09-13
WL#5096: Write test cases for WL 5092
Some rpl_row_img tests would still make PB2 timeout on
valgrind runs, because they would take too long to complete
(after latest pull from main).
We unfold the inner loop on the test files and split the
original test files per test group and per different
binlog-row-image value.
added:
mysql-test/suite/rpl/r/rpl_row_img_eng_min.result
mysql-test/suite/rpl/r/rpl_row_img_eng_noblob.result
mysql-test/suite/rpl/r/rpl_row_img_idx_min.result
mysql-test/suite/rpl/r/rpl_row_img_idx_noblob.result
mysql-test/suite/rpl/t/rpl_row_img_eng_min.cnf
mysql-test/suite/rpl/t/rpl_row_img_eng_min.test
mysql-test/suite/rpl/t/rpl_row_img_eng_noblob.cnf
mysql-test/suite/rpl/t/rpl_row_img_eng_noblob.test
mysql-test/suite/rpl/t/rpl_row_img_idx_min.cnf
mysql-test/suite/rpl/t/rpl_row_img_idx_min.test
mysql-test/suite/rpl/t/rpl_row_img_idx_noblob.cnf
mysql-test/suite/rpl/t/rpl_row_img_idx_noblob.test
renamed:
mysql-test/suite/rpl/r/rpl_row_img_engines.result => mysql-test/suite/rpl/r/rpl_row_img_eng_full.result
mysql-test/suite/rpl/r/rpl_row_img_indexes.result => mysql-test/suite/rpl/r/rpl_row_img_idx_full.result
mysql-test/suite/rpl/t/rpl_row_img_engines.cnf => mysql-test/suite/rpl/t/rpl_row_img_eng_full.cnf
mysql-test/suite/rpl/t/rpl_row_img_engines.test => mysql-test/suite/rpl/t/rpl_row_img_eng_full.test
mysql-test/suite/rpl/t/rpl_row_img_indexes.cnf => mysql-test/suite/rpl/t/rpl_row_img_idx_full.cnf
mysql-test/suite/rpl/t/rpl_row_img_indexes.test => mysql-test/suite/rpl/t/rpl_row_img_idx_full.test
modified:
mysql-test/include/rpl_row_img_general_loop.inc
mysql-test/suite/rpl/r/rpl_row_img_blobs.result
mysql-test/suite/rpl/t/rpl_row_img_blobs.test
mysql-test/suite/rpl/r/rpl_row_img_eng_full.result
mysql-test/suite/rpl/r/rpl_row_img_idx_full.result
mysql-test/suite/rpl/t/rpl_row_img_eng_full.test
mysql-test/suite/rpl/t/rpl_row_img_idx_full.test
=== modified file 'client/CMakeLists.txt'
--- a/client/CMakeLists.txt 2010-08-12 15:19:57 +0000
+++ b/client/CMakeLists.txt 2010-09-06 11:26:23 +0000
@@ -64,7 +64,10 @@ MYSQL_ADD_EXECUTABLE(mysqlslap mysqlslap
SET_SOURCE_FILES_PROPERTIES(mysqlslap.c PROPERTIES COMPILE_FLAGS "-DTHREADS")
TARGET_LINK_LIBRARIES(mysqlslap mysqlclient)
-ADD_EXECUTABLE(echo echo.c)
+# "WIN32" also covers 64 bit. "echo" is used in some files below "mysql-test/".
+IF(WIN32)
+ MYSQL_ADD_EXECUTABLE(echo echo.c)
+ENDIF(WIN32)
SET_TARGET_PROPERTIES (mysqlcheck mysqldump mysqlimport mysql_upgrade mysqlshow mysqlslap
PROPERTIES HAS_CXX TRUE)
=== modified file 'include/CMakeLists.txt'
--- a/include/CMakeLists.txt 2010-08-12 15:27:53 +0000
+++ b/include/CMakeLists.txt 2010-09-13 10:26:57 +0000
@@ -54,6 +54,7 @@ SET(HEADERS
keycache.h
m_ctype.h
my_attribute.h
+ my_compiler.h
${HEADERS_GEN_CONFIGURE}
)
=== modified file 'include/Makefile.am'
--- a/include/Makefile.am 2010-09-01 13:05:01 +0000
+++ b/include/Makefile.am 2010-09-13 10:36:27 +0000
@@ -32,8 +32,9 @@ pkginclude_HEADERS = $(HEADERS_ABI) my_d
decimal.h errmsg.h my_global.h my_net.h \
my_getopt.h sslopt-longopts.h my_dir.h \
sslopt-vars.h sslopt-case.h sql_common.h keycache.h \
- m_ctype.h my_attribute.h $(HEADERS_GEN_CONFIGURE) \
- $(HEADERS_GEN_MAKE) probes_mysql.h probes_mysql_nodtrace.h
+ m_ctype.h my_attribute.h my_compiler.h \
+ $(HEADERS_GEN_CONFIGURE) $(HEADERS_GEN_MAKE) \
+ probes_mysql.h probes_mysql_nodtrace.h
noinst_HEADERS = lf.h my_bit.h \
heap.h my_bitmap.h my_uctype.h password.h \
@@ -47,7 +48,7 @@ noinst_HEADERS = lf.h my_bit.h \
my_user.h my_atomic.h atomic/nolock.h \
atomic/rwlock.h atomic/x86-gcc.h atomic/generic-msvc.h \
atomic/gcc_builtins.h my_libwrap.h my_stacktrace.h \
- atomic/solaris.h mysql/innodb_priv.h my_compiler.h
+ atomic/solaris.h mysql/innodb_priv.h
pkgpsiinclude_HEADERS = mysql/psi/psi.h mysql/psi/mysql_thread.h \
mysql/psi/mysql_file.h \
=== modified file 'mysql-test/r/sp-destruct.result'
--- a/mysql-test/r/sp-destruct.result 2010-03-03 09:24:53 +0000
+++ b/mysql-test/r/sp-destruct.result 2010-09-13 09:58:11 +0000
@@ -134,3 +134,19 @@ Warning 1405 Failed to revoke all privil
# Restore the procs_priv table
RENAME TABLE procs_priv_backup TO mysql.procs_priv;
FLUSH TABLE mysql.procs_priv;
+#
+# Bug #56137 "Assertion `thd->lock == 0' failed on upgrading from
+# 5.1.50 to 5.5.6".
+#
+drop database if exists mysqltest;
+# Backup mysql.proc.
+flush table mysql.proc;
+create database mysqltest;
+# Corrupt mysql.proc to make it unusable by current version of server.
+alter table mysql.proc drop column type;
+# The below statement should not cause assertion failure.
+drop database mysqltest;
+Warnings:
+Error 1695 Column count of mysql.proc is wrong. Expected 20, found 19. The table is probably corrupted
+# Restore mysql.proc.
+drop table mysql.proc;
=== modified file 'mysql-test/t/sp-destruct.test'
--- a/mysql-test/t/sp-destruct.test 2010-04-16 14:24:06 +0000
+++ b/mysql-test/t/sp-destruct.test 2010-09-13 09:58:11 +0000
@@ -222,3 +222,33 @@ SHOW WARNINGS;
--echo # Restore the procs_priv table
RENAME TABLE procs_priv_backup TO mysql.procs_priv;
FLUSH TABLE mysql.procs_priv;
+
+
+--echo #
+--echo # Bug #56137 "Assertion `thd->lock == 0' failed on upgrading from
+--echo # 5.1.50 to 5.5.6".
+--echo #
+--disable_warnings
+drop database if exists mysqltest;
+--enable_warnings
+--echo # Backup mysql.proc.
+flush table mysql.proc;
+let $MYSQLD_DATADIR= `select @@datadir`;
+--copy_file $MYSQLD_DATADIR/mysql/proc.frm $MYSQLTEST_VARDIR/tmp/proc.frm
+--copy_file $MYSQLD_DATADIR/mysql/proc.MYD $MYSQLTEST_VARDIR/tmp/proc.MYD
+--copy_file $MYSQLD_DATADIR/mysql/proc.MYI $MYSQLTEST_VARDIR/tmp/proc.MYI
+
+create database mysqltest;
+--echo # Corrupt mysql.proc to make it unusable by current version of server.
+alter table mysql.proc drop column type;
+--echo # The below statement should not cause assertion failure.
+drop database mysqltest;
+
+--echo # Restore mysql.proc.
+drop table mysql.proc;
+--copy_file $MYSQLTEST_VARDIR/tmp/proc.frm $MYSQLD_DATADIR/mysql/proc.frm
+--copy_file $MYSQLTEST_VARDIR/tmp/proc.MYD $MYSQLD_DATADIR/mysql/proc.MYD
+--copy_file $MYSQLTEST_VARDIR/tmp/proc.MYI $MYSQLD_DATADIR/mysql/proc.MYI
+--remove_file $MYSQLTEST_VARDIR/tmp/proc.frm
+--remove_file $MYSQLTEST_VARDIR/tmp/proc.MYD
+--remove_file $MYSQLTEST_VARDIR/tmp/proc.MYI
=== modified file 'scripts/CMakeLists.txt'
--- a/scripts/CMakeLists.txt 2010-08-23 17:01:12 +0000
+++ b/scripts/CMakeLists.txt 2010-09-13 10:26:57 +0000
@@ -139,6 +139,7 @@ ELSE()
ENDIF()
SET(HOSTNAME "hostname")
+SET(MYSQLD_USER "mysql")
# Required for mysqlbug until autotools are deprecated, once done remove these
# and expand default cmake variables
=== modified file 'scripts/make_win_bin_dist'
--- a/scripts/make_win_bin_dist 2010-07-23 20:14:04 +0000
+++ b/scripts/make_win_bin_dist 2010-08-31 14:33:19 +0000
@@ -260,6 +260,7 @@ cp include/mysql.h \
include/keycache.h \
include/m_ctype.h \
include/my_attribute.h \
+ include/my_compiler.h \
include/mysqld_error.h \
include/sql_state.h \
include/mysqld_ername.h \
=== modified file 'sql/CMakeLists.txt'
--- a/sql/CMakeLists.txt 2010-08-20 09:15:16 +0000
+++ b/sql/CMakeLists.txt 2010-09-13 12:15:56 +0000
@@ -289,8 +289,7 @@ IF(WIN32 AND MYSQLD_EXECUTABLE)
COMMAND ${CMAKE_COMMAND}
${CONFIG_PARAM} -P ${CMAKE_CURRENT_BINARY_DIR}/create_initial_db.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/data
- COMMAND ${CMAKE_COMMAND} -E touch initdb.dep
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/initdb.dep
DEPENDS mysqld
)
ADD_CUSTOM_TARGET(initial_database
=== modified file 'sql/mdl.cc'
--- a/sql/mdl.cc 2010-08-20 08:48:59 +0000
+++ b/sql/mdl.cc 2010-09-13 10:26:57 +0000
@@ -124,7 +124,6 @@ public:
Deadlock_detection_visitor(MDL_context *start_node_arg)
: m_start_node(start_node_arg),
m_victim(NULL),
- m_current_search_depth(0),
m_found_deadlock(FALSE)
{}
virtual bool enter_node(MDL_context *node);
@@ -133,6 +132,8 @@ public:
virtual bool inspect_edge(MDL_context *dest);
MDL_context *get_victim() const { return m_victim; }
+
+ void abort_traversal(MDL_context *node);
private:
/**
Change the deadlock victim to a new one if it has lower deadlock
@@ -147,13 +148,6 @@ private:
MDL_context *m_start_node;
/** If a deadlock is found, the context that identifies the victim. */
MDL_context *m_victim;
- /** Set to the 0 at start. Increased whenever
- we descend into another MDL context (aka traverse to the next
- wait-for graph node). When MAX_SEARCH_DEPTH is reached, we
- assume that a deadlock is found, even if we have not found a
- loop.
- */
- uint m_current_search_depth;
/** TRUE if we found a deadlock. */
bool m_found_deadlock;
/**
@@ -187,7 +181,7 @@ private:
bool Deadlock_detection_visitor::enter_node(MDL_context *node)
{
- m_found_deadlock= ++m_current_search_depth >= MAX_SEARCH_DEPTH;
+ m_found_deadlock= m_current_search_depth >= MAX_SEARCH_DEPTH;
if (m_found_deadlock)
{
DBUG_ASSERT(! m_victim);
@@ -207,7 +201,6 @@ bool Deadlock_detection_visitor::enter_n
void Deadlock_detection_visitor::leave_node(MDL_context *node)
{
- --m_current_search_depth;
if (m_found_deadlock)
opt_change_victim_to(node);
}
@@ -252,6 +245,21 @@ Deadlock_detection_visitor::opt_change_v
/**
+ Abort traversal of a wait-for graph and report a deadlock.
+
+ @param node Node which we were about to visit when abort
+ was initiated.
+*/
+
+void Deadlock_detection_visitor::abort_traversal(MDL_context *node)
+{
+ DBUG_ASSERT(! m_victim);
+ m_found_deadlock= TRUE;
+ opt_change_victim_to(node);
+}
+
+
+/**
Get a bit corresponding to enum_mdl_type value in a granted/waiting bitmaps
and compatibility matrices.
*/
@@ -2056,8 +2064,13 @@ bool MDL_lock::visit_subgraph(MDL_ticket
are visiting it but this is OK: in the worst case we might do some
extra work and one more context might be chosen as a victim.
*/
+ ++gvisitor->m_current_search_depth;
+
if (gvisitor->enter_node(src_ctx))
+ {
+ --gvisitor->m_current_search_depth;
goto end;
+ }
/*
We do a breadth-first search first -- that is, inspect all
@@ -2114,6 +2127,7 @@ bool MDL_lock::visit_subgraph(MDL_ticket
end_leave_node:
gvisitor->leave_node(src_ctx);
+ --gvisitor->m_current_search_depth;
end:
mysql_prlock_unlock(&m_rwlock);
=== modified file 'sql/mdl.h'
--- a/sql/mdl.h 2010-08-20 08:48:59 +0000
+++ b/sql/mdl.h 2010-09-13 10:26:57 +0000
@@ -385,7 +385,10 @@ public:
virtual bool inspect_edge(MDL_context *dest) = 0;
virtual ~MDL_wait_for_graph_visitor();
- MDL_wait_for_graph_visitor() :m_lock_open_count(0) {}
+ MDL_wait_for_graph_visitor() :m_lock_open_count(0),
+ m_current_search_depth(0)
+ { }
+ virtual void abort_traversal(MDL_context *node) = 0;
public:
/**
XXX, hack: During deadlock search, we may need to
@@ -396,6 +399,17 @@ public:
LOCK_open since it has significant performance impacts.
*/
uint m_lock_open_count;
+ /**
+ Set to the 0 at start. Increased whenever
+ we descend into another MDL context (aka traverse to the next
+ wait-for graph node). When MAX_SEARCH_DEPTH is reached, we
+ assume that a deadlock is found, even if we have not found a
+ loop.
+
+ XXX: This member belongs to this class only temporarily until
+ bug #56405 is fixed.
+ */
+ uint m_current_search_depth;
};
/**
=== modified file 'sql/sp.cc'
--- a/sql/sp.cc 2010-08-06 08:54:01 +0000
+++ b/sql/sp.cc 2010-09-13 12:15:56 +0000
@@ -440,6 +440,7 @@ static TABLE *open_proc_table_for_update
{
TABLE_LIST table_list;
TABLE *table;
+ MDL_ticket *mdl_savepoint= thd->mdl_context.mdl_savepoint();
DBUG_ENTER("open_proc_table_for_update");
table_list.init_one_table("mysql", 5, "proc", 4, "proc", TL_WRITE);
@@ -450,6 +451,9 @@ static TABLE *open_proc_table_for_update
if (!proc_table_intact.check(table, &proc_table_def))
DBUG_RETURN(table);
+ close_thread_tables(thd);
+ thd->mdl_context.rollback_to_savepoint(mdl_savepoint);
+
DBUG_RETURN(NULL);
}
=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc 2010-08-20 09:15:16 +0000
+++ b/sql/sql_base.cc 2010-09-13 12:15:56 +0000
@@ -100,6 +100,8 @@ bool No_such_table_error_handler::safely
TABLE_SHAREs, refresh_version and the table id counter.
*/
mysql_mutex_t LOCK_open;
+mysql_mutex_t LOCK_dd_owns_lock_open;
+uint dd_owns_lock_open= 0;
#ifdef HAVE_PSI_INTERFACE
static PSI_mutex_key key_LOCK_open;
@@ -298,6 +300,7 @@ bool table_def_init(void)
init_tdc_psi_keys();
#endif
mysql_mutex_init(key_LOCK_open, &LOCK_open, MY_MUTEX_INIT_FAST);
+ mysql_mutex_init(NULL, &LOCK_dd_owns_lock_open, MY_MUTEX_INIT_FAST);
oldest_unused_share= &end_of_unused_share;
end_of_unused_share.prev= &oldest_unused_share;
@@ -341,6 +344,7 @@ void table_def_free(void)
table_def_inited= 0;
/* Free table definitions. */
my_hash_free(&table_def_cache);
+ mysql_mutex_destroy(&LOCK_dd_owns_lock_open);
mysql_mutex_destroy(&LOCK_open);
}
DBUG_VOID_RETURN;
=== modified file 'sql/sql_base.h'
--- a/sql/sql_base.h 2010-08-20 09:15:16 +0000
+++ b/sql/sql_base.h 2010-09-13 12:15:56 +0000
@@ -71,6 +71,8 @@ enum enum_tdc_remove_table_type {TDC_RT_
bool check_dup(const char *db, const char *name, TABLE_LIST *tables);
extern mysql_mutex_t LOCK_open;
+extern mysql_mutex_t LOCK_dd_owns_lock_open;
+extern uint dd_owns_lock_open;
bool table_cache_init(void);
void table_cache_free(void);
bool table_def_init(void);
=== modified file 'sql/table.cc'
--- a/sql/table.cc 2010-09-04 00:46:58 +0000
+++ b/sql/table.cc 2010-09-16 10:30:57 +0000
@@ -3086,7 +3086,30 @@ bool TABLE_SHARE::visit_subgraph(Wait_fo
holding a write-lock on MDL_lock::m_rwlock.
*/
if (gvisitor->m_lock_open_count++ == 0)
+ {
+ /*
+ To circumvent bug #56405 "Deadlock in the MDL deadlock detector"
+ we don't try to lock LOCK_open mutex if some thread doing
+ deadlock detection already owns it and current search depth is
+ greater than 0. Instead we report a deadlock.
+
+ TODO/FIXME: The proper fix for this bug is to use rwlocks for
+ protection of table shares/instead of LOCK_open.
+ Unfortunately it requires more effort/has significant
+ performance effect.
+ */
+ mysql_mutex_lock(&LOCK_dd_owns_lock_open);
+ if (gvisitor->m_current_search_depth > 0 && dd_owns_lock_open > 0)
+ {
+ mysql_mutex_unlock(&LOCK_dd_owns_lock_open);
+ --gvisitor->m_lock_open_count;
+ gvisitor->abort_traversal(src_ctx);
+ return TRUE;
+ }
+ ++dd_owns_lock_open;
+ mysql_mutex_unlock(&LOCK_dd_owns_lock_open);
mysql_mutex_lock(&LOCK_open);
+ }
I_P_List_iterator <TABLE, TABLE_share> tables_it(used_tables);
@@ -3101,8 +3124,12 @@ bool TABLE_SHARE::visit_subgraph(Wait_fo
goto end;
}
+ ++gvisitor->m_current_search_depth;
if (gvisitor->enter_node(src_ctx))
+ {
+ --gvisitor->m_current_search_depth;
goto end;
+ }
while ((table= tables_it++))
{
@@ -3125,10 +3152,16 @@ bool TABLE_SHARE::visit_subgraph(Wait_fo
end_leave_node:
gvisitor->leave_node(src_ctx);
+ --gvisitor->m_current_search_depth;
end:
if (gvisitor->m_lock_open_count-- == 1)
+ {
mysql_mutex_unlock(&LOCK_open);
+ mysql_mutex_lock(&LOCK_dd_owns_lock_open);
+ --dd_owns_lock_open;
+ mysql_mutex_unlock(&LOCK_dd_owns_lock_open);
+ }
return result;
}
Attachment: [text/bzr-bundle] bzr/luis.soares@oracle.com-20100916103057-ijdich0wn6bhojs2.bundle
| Thread |
|---|
| • bzr push into mysql-next-mr-wl5092 branch (luis.soares:3158 to 3159) | Luis Soares | 16 Sep |