Commit 420c4dcc authored by Kentoku SHIBA's avatar Kentoku SHIBA

MDEV-7098 spider/bg.spider_fixes failed in buildbot with safe_mutex: Trying to...

MDEV-7098 spider/bg.spider_fixes failed in buildbot with safe_mutex: Trying to unlock mutex conn->mta_conn_mutex that wasn't locked at storage/spider/spd_db_conn.cc, line 671
parent 3ee24226
This diff is collapsed.
...@@ -2390,6 +2390,7 @@ void *spider_bg_conn_action( ...@@ -2390,6 +2390,7 @@ void *spider_bg_conn_action(
sql_type = SPIDER_SQL_TYPE_SELECT_HS; sql_type = SPIDER_SQL_TYPE_SELECT_HS;
} }
#endif #endif
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
if (dbton_handler->need_lock_before_set_sql_for_exec(sql_type)) if (dbton_handler->need_lock_before_set_sql_for_exec(sql_type))
{ {
pthread_mutex_lock(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex);
...@@ -2419,6 +2420,8 @@ void *spider_bg_conn_action( ...@@ -2419,6 +2420,8 @@ void *spider_bg_conn_action(
if (!result_list->bgs_error) if (!result_list->bgs_error)
{ {
conn->need_mon = &spider->need_mons[conn->link_idx]; conn->need_mon = &spider->need_mons[conn->link_idx];
DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later);
conn->mta_conn_mutex_lock_already = TRUE; conn->mta_conn_mutex_lock_already = TRUE;
conn->mta_conn_mutex_unlock_later = TRUE; conn->mta_conn_mutex_unlock_later = TRUE;
#ifdef HA_CAN_BULK_ACCESS #ifdef HA_CAN_BULK_ACCESS
...@@ -2496,6 +2499,8 @@ void *spider_bg_conn_action( ...@@ -2496,6 +2499,8 @@ void *spider_bg_conn_action(
#ifdef HA_CAN_BULK_ACCESS #ifdef HA_CAN_BULK_ACCESS
} }
#endif #endif
DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_lock_already = FALSE;
conn->mta_conn_mutex_unlock_later = FALSE; conn->mta_conn_mutex_unlock_later = FALSE;
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
...@@ -2506,11 +2511,14 @@ void *spider_bg_conn_action( ...@@ -2506,11 +2511,14 @@ void *spider_bg_conn_action(
} }
} else { } else {
spider->connection_ids[conn->link_idx] = conn->connection_id; spider->connection_ids[conn->link_idx] = conn->connection_id;
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later);
conn->mta_conn_mutex_unlock_later = TRUE; conn->mta_conn_mutex_unlock_later = TRUE;
result_list->bgs_error = result_list->bgs_error =
spider_db_store_result(spider, conn->link_idx, result_list->table); spider_db_store_result(spider, conn->link_idx, result_list->table);
if ((result_list->bgs_error_with_message = thd->is_error())) if ((result_list->bgs_error_with_message = thd->is_error()))
strmov(result_list->bgs_error_msg, spider_stmt_da_message(thd)); strmov(result_list->bgs_error_msg, spider_stmt_da_message(thd));
DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
conn->mta_conn_mutex_unlock_later = FALSE; conn->mta_conn_mutex_unlock_later = FALSE;
} }
conn->bg_search = FALSE; conn->bg_search = FALSE;
...@@ -2574,12 +2582,26 @@ void *spider_bg_conn_action( ...@@ -2574,12 +2582,26 @@ void *spider_bg_conn_action(
{ {
DBUG_PRINT("info",("spider bg exec sql start")); DBUG_PRINT("info",("spider bg exec sql start"));
spider = (ha_spider*) conn->bg_target; spider = (ha_spider*) conn->bg_target;
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
pthread_mutex_lock(&conn->mta_conn_mutex);
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
conn->need_mon = &spider->need_mons[conn->link_idx];
DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later);
conn->mta_conn_mutex_lock_already = TRUE;
conn->mta_conn_mutex_unlock_later = TRUE;
*conn->bg_error_num = spider_db_query_with_set_names( *conn->bg_error_num = spider_db_query_with_set_names(
conn->bg_sql_type, conn->bg_sql_type,
spider, spider,
conn, conn,
conn->link_idx conn->link_idx
); );
DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
conn->mta_conn_mutex_lock_already = FALSE;
conn->mta_conn_mutex_unlock_later = FALSE;
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
conn->bg_exec_sql = FALSE; conn->bg_exec_sql = FALSE;
continue; continue;
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#define SPIDER_HEX_VERSION 0x0302 #define SPIDER_HEX_VERSION 0x0302
#if MYSQL_VERSION_ID < 50500 #if MYSQL_VERSION_ID < 50500
#define pthread_mutex_assert_owner(A)
#define pthread_mutex_assert_not_owner(A)
#else #else
#define my_free(A,B) my_free(A) #define my_free(A,B) my_free(A)
#ifdef pthread_mutex_t #ifdef pthread_mutex_t
...@@ -39,6 +41,8 @@ ...@@ -39,6 +41,8 @@
#undef pthread_mutex_destroy #undef pthread_mutex_destroy
#endif #endif
#define pthread_mutex_destroy mysql_mutex_destroy #define pthread_mutex_destroy mysql_mutex_destroy
#define pthread_mutex_assert_owner(A) mysql_mutex_assert_owner(A)
#define pthread_mutex_assert_not_owner(A) mysql_mutex_assert_not_owner(A)
#ifdef pthread_cond_t #ifdef pthread_cond_t
#undef pthread_cond_t #undef pthread_cond_t
#endif #endif
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment