Permalink
Browse files

temp commit: fixed that metadata locks for tables are not acquired (5…

….5.x only).
  • Loading branch information...
1 parent f51e061 commit de48e4be40c47d47fdaff0990f1c4f005dc3faac @ahiguti committed Jan 14, 2011
Showing with 37 additions and 28 deletions.
  1. +12 −2 configure.ac
  2. +25 −23 handlersocket/database.cpp
  3. +0 −3 handlersocket/mysql_incl.hpp
View
14 configure.ac
@@ -13,6 +13,12 @@ AC_PROG_CXX
AC_PROG_CPP
AC_PROG_LIBTOOL
+ac_mysql_debug=
+AC_ARG_ENABLE(mysql-debug,
+ [AS_HELP_STRING([--enable-mysql-debug], [specify whether MySQL is build with DBUG_ON])],[ac_mysql_debug="$enableval"],[ac_mysql_debug=no])
+AC_MSG_CHECKING([if --enable-mysql-debug is specified])
+AC_MSG_RESULT($ac_mysql_debug)
+
AC_DEFUN([CONFIG_OPTION_MYSQL],[
AC_MSG_CHECKING([mysql source])
@@ -66,8 +72,12 @@ AC_DEFUN([CONFIG_OPTION_MYSQL],[
fi
MYSQL_CFLAGS_ADD=`"$ac_mysql_config" --cflags`
- MYSQL_CFLAGS="$MYSQL_CFLAGS $MYSQL_CFLAGS_ADD -DFORCE_DBUG_OFF"
- # FIXME
+ MYSQL_CFLAGS="$MYSQL_CFLAGS $MYSQL_CFLAGS_ADD"
+ if test "$ac_mysql_debug" = "yes"; then
+ MYSQL_CFLAGS="$MYSQL_CFLAGS -DDBUG_ON -DENABLED_DEBUG_SYNC"
+ else
+ MYSQL_CFLAGS="$MYSQL_CFLAGS -DDBUG_OFF"
+ fi
AC_SUBST(MYSQL_CFLAGS)
MYSQL_BIN_VERSION=`"$ac_mysql_config" --version`
View
48 handlersocket/database.cpp
@@ -185,11 +185,6 @@ struct dbcontext : public dbcontext_i, private noncopyable {
std::vector<char> info_message_buf;
table_vec_type table_vec;
table_map_type table_map;
- #if MYSQL_VERSION_ID >= 50505
- MDL_request *mdl_request;
- #else
- void *mdl_request;
- #endif
};
database::database(const config& c)
@@ -228,7 +223,7 @@ database_i::create(const config& conf)
dbcontext::dbcontext(volatile database *d, bool for_write)
: dbref(d), for_write_flag(for_write), thd(0), lock(0), lock_failed(false),
user_level_lock_timeout(0), user_level_lock_locked(false),
- commit_error(false), mdl_request(0)
+ commit_error(false)
{
info_message_buf.resize(8192);
user_level_lock_timeout = d->get_conf().get_int("wrlock_timeout", 12);
@@ -275,6 +270,8 @@ wait_server_to_start(THD *thd, volatile int& shutdown_flag)
}; // namespace
+#define DENA_THR_OFFSETOF(fld) ((char *)(&thd->fld) - (char *)thd)
+
void
dbcontext::init_thread(const void *stack_bottom, volatile int& shutdown_flag)
{
@@ -283,9 +280,17 @@ dbcontext::init_thread(const void *stack_bottom, volatile int& shutdown_flag)
my_thread_init();
thd = new THD;
thd->thread_stack = (char *)stack_bottom;
- DBG_THR(const size_t of = (char *)(&thd->thread_stack) - (char *)thd);
- DBG_THR(fprintf(stderr, "thread_stack = %p sz=%zu of=%zu\n",
- thd->thread_stack, sizeof(THD), of));
+ DBG_THR(fprintf(stderr,
+ "thread_stack = %p sizeof(THD)=%zu sizeof(mtx)=%zu "
+ "O: %zu %zu %zu %zu %zu %zu %zu\n",
+ thd->thread_stack, sizeof(THD), sizeof(LOCK_thread_count),
+ DENA_THR_OFFSETOF(mdl_context),
+ DENA_THR_OFFSETOF(net),
+ DENA_THR_OFFSETOF(LOCK_thd_data),
+ DENA_THR_OFFSETOF(mysys_var),
+ DENA_THR_OFFSETOF(stmt_arena),
+ DENA_THR_OFFSETOF(limit_found_rows),
+ DENA_THR_OFFSETOF(locked_tables_list)));
thd->store_globals();
thd->system_thread = static_cast<enum_thread_type>(1<<30UL);
const NET v = { 0 };
@@ -319,16 +324,6 @@ dbcontext::init_thread(const void *stack_bottom, volatile int& shutdown_flag)
set_thread_message("hs:listening");
DBG_THR(fprintf(stderr, "HNDSOCK x1 %p\n", thd));
- /* TODO: implement proper metadata locking */
- #if MYSQL_VERSION_ID >= 50508
- mdl_request = new(thd->mem_root) MDL_request;
- mdl_request->init(MDL_key::TABLE, "", "",
- for_write_flag ? MDL_SHARED_WRITE : MDL_SHARED_READ, MDL_STATEMENT);
- #elif MYSQL_VERSION_ID >= 50505
- mdl_request = MDL_request::create(MDL_key::TABLE, "", "",
- for_write_flag ? MDL_SHARED_WRITE : MDL_SHARED_READ, thd->mem_root);
- #endif
-
lex_start(thd);
user_lock.reset(new expr_user_lock(thd, user_level_lock_timeout));
@@ -432,13 +427,17 @@ void
dbcontext::unlock_tables_if()
{
if (lock != 0) {
- DENA_VERBOSE(100, fprintf(stderr, "HNDSOCK unlock tables\n"));
+ DENA_VERBOSE(100, fprintf(stderr, "HNDSOCK unlock tables %p %p\n",
+ thd, thd->lock));
if (for_write_flag) {
for (size_t i = 0; i < table_vec.size(); ++i) {
if (table_vec[i].modified) {
query_cache_invalidate3(thd, table_vec[i].table, 1);
+ table_vec[i].table->file->ha_release_auto_increment();
}
}
+ }
+ {
bool suc = true;
#if MYSQL_VERSION_ID >= 50505
suc = (trans_commit_stmt(thd) == 0);
@@ -482,6 +481,9 @@ dbcontext::close_tables_if()
if (!table_vec.empty()) {
DENA_VERBOSE(100, fprintf(stderr, "HNDSOCK close tables\n"));
close_thread_tables(thd);
+ #if MYSQL_VERSION_ID >= 50505
+ thd->mdl_context.release_transactional_locks();
+ #endif
statistic_increment(close_tables_count, &LOCK_status);
table_vec.clear();
table_map.clear();
@@ -547,7 +549,6 @@ dbcontext::dump_record(dbcallback_i& cb, TABLE *const table,
Field *const fld = table->field[fn];
if (fld->is_null()) {
/* null */
- cb.dbcb_resp_entry(0, 0);
fprintf(stderr, "NULL");
} else {
fld->val_str(&rwpstr, &rwpstr);
@@ -983,8 +984,9 @@ dbcontext::cmd_open_index(dbcallback_i& cb, size_t pst_id, const char *dbn,
#if MYSQL_VERSION_ID >= 50505
tables.init_one_table(dbn, strlen(dbn), tbl, strlen(tbl), tbl,
lock_type);
- tables.mdl_request = mdl_request;
- Open_table_context ot_act(thd, MYSQL_OPEN_REOPEN);
+ tables.mdl_request.init(MDL_key::TABLE, dbn, tbl,
+ for_write_flag ? MDL_SHARED_WRITE : MDL_SHARED_READ, MDL_TRANSACTION);
+ Open_table_context ot_act(thd, 0);
if (!open_table(thd, &tables, thd->mem_root, &ot_act)) {
table = tables.table;
}
View
3 handlersocket/mysql_incl.hpp
@@ -17,9 +17,6 @@
#define MYSQL_SERVER 1
#include <my_config.h>
-#ifdef DBUG_ON
-#define SAFE_MUTEX
-#endif
#include <mysql_version.h>

0 comments on commit de48e4b

Please sign in to comment.