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

This commit is contained in:
Kentoku SHIBA 2020-09-04 22:10:57 +09:00
parent c029d45623
commit 9dedba16ab
7 changed files with 1534 additions and 539 deletions

View file

@ -2258,6 +2258,7 @@ int ha_spider::index_read_map_internal(
}
#endif
spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id];
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
{
pthread_mutex_lock(&conn->mta_conn_mutex);
@ -2265,6 +2266,11 @@ int ha_spider::index_read_map_internal(
}
if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count)))
{
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
{
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
DBUG_RETURN(error_num);
}
if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
@ -2286,11 +2292,15 @@ int ha_spider::index_read_map_internal(
} else {
#endif
conn->need_mon = &need_mons[roop_count];
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;
if ((error_num = spider_db_set_names(this, conn,
roop_count)))
{
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);
@ -2325,6 +2335,8 @@ int ha_spider::index_read_map_internal(
result_list.quick_mode,
&need_mons[roop_count])
) {
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;
error_num = spider_db_errorno(conn);
@ -2351,6 +2363,8 @@ int ha_spider::index_read_map_internal(
DBUG_RETURN(check_error_mode_eof(error_num));
}
connection_ids[roop_count] = conn->connection_id;
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;
if (roop_count == link_ok)
@ -2750,6 +2764,7 @@ int ha_spider::index_read_last_map_internal(
}
#endif
spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id];
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
{
pthread_mutex_lock(&conn->mta_conn_mutex);
@ -2757,6 +2772,11 @@ int ha_spider::index_read_last_map_internal(
}
if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count)))
{
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
{
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
DBUG_RETURN(error_num);
}
if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
@ -2775,11 +2795,15 @@ int ha_spider::index_read_last_map_internal(
} else {
#endif
conn->need_mon = &need_mons[roop_count];
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;
if ((error_num = spider_db_set_names(this, conn,
roop_count)))
{
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);
@ -2814,6 +2838,8 @@ int ha_spider::index_read_last_map_internal(
result_list.quick_mode,
&need_mons[roop_count])
) {
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;
error_num = spider_db_errorno(conn);
@ -2840,6 +2866,8 @@ int ha_spider::index_read_last_map_internal(
DBUG_RETURN(check_error_mode_eof(error_num));
}
connection_ids[roop_count] = conn->connection_id;
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;
if (roop_count == link_ok)
@ -3216,6 +3244,7 @@ int ha_spider::index_first_internal(
}
#endif
spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id];
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
{
pthread_mutex_lock(&conn->mta_conn_mutex);
@ -3224,6 +3253,11 @@ int ha_spider::index_first_internal(
if ((error_num =
dbton_hdl->set_sql_for_exec(sql_type, roop_count)))
{
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
{
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
DBUG_RETURN(error_num);
}
if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
@ -3242,11 +3276,15 @@ int ha_spider::index_first_internal(
} else {
#endif
conn->need_mon = &need_mons[roop_count];
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;
if ((error_num = spider_db_set_names(this, conn,
roop_count)))
{
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);
@ -3281,6 +3319,8 @@ int ha_spider::index_first_internal(
result_list.quick_mode,
&need_mons[roop_count])
) {
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;
error_num = spider_db_errorno(conn);
@ -3307,6 +3347,8 @@ int ha_spider::index_first_internal(
DBUG_RETURN(check_error_mode_eof(error_num));
}
connection_ids[roop_count] = conn->connection_id;
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;
if (roop_count == link_ok)
@ -3600,6 +3642,7 @@ int ha_spider::index_last_internal(
}
#endif
spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id];
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
{
pthread_mutex_lock(&conn->mta_conn_mutex);
@ -3608,6 +3651,11 @@ int ha_spider::index_last_internal(
if ((error_num =
dbton_hdl->set_sql_for_exec(sql_type, roop_count)))
{
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
{
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
DBUG_RETURN(error_num);
}
if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
@ -3626,11 +3674,15 @@ int ha_spider::index_last_internal(
} else {
#endif
conn->need_mon = &need_mons[roop_count];
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;
if ((error_num = spider_db_set_names(this, conn,
roop_count)))
{
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);
@ -3665,6 +3717,8 @@ int ha_spider::index_last_internal(
result_list.quick_mode,
&need_mons[roop_count])
) {
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;
error_num = spider_db_errorno(conn);
@ -3691,6 +3745,8 @@ int ha_spider::index_last_internal(
DBUG_RETURN(check_error_mode_eof(error_num));
}
connection_ids[roop_count] = conn->connection_id;
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;
if (roop_count == link_ok)
@ -4044,6 +4100,7 @@ int ha_spider::read_range_first_internal(
}
#endif
spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id];
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
{
pthread_mutex_lock(&conn->mta_conn_mutex);
@ -4051,6 +4108,11 @@ int ha_spider::read_range_first_internal(
}
if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count)))
{
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
{
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
DBUG_RETURN(error_num);
}
if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
@ -4069,11 +4131,15 @@ int ha_spider::read_range_first_internal(
} else {
#endif
conn->need_mon = &need_mons[roop_count];
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;
if ((error_num = spider_db_set_names(this, conn,
roop_count)))
{
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);
@ -4108,6 +4174,8 @@ int ha_spider::read_range_first_internal(
result_list.quick_mode,
&need_mons[roop_count])
) {
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;
error_num = spider_db_errorno(conn);
@ -4134,6 +4202,8 @@ int ha_spider::read_range_first_internal(
DBUG_RETURN(check_error_mode_eof(error_num));
}
connection_ids[roop_count] = conn->connection_id;
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;
if (roop_count == link_ok)
@ -4670,6 +4740,7 @@ int ha_spider::read_multi_range_first_internal(
}
#endif
spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id];
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
{
pthread_mutex_lock(&conn->mta_conn_mutex);
@ -4678,6 +4749,11 @@ int ha_spider::read_multi_range_first_internal(
if ((error_num =
dbton_hdl->set_sql_for_exec(sql_type, roop_count)))
{
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
{
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
DBUG_RETURN(error_num);
}
if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
@ -4702,11 +4778,15 @@ int ha_spider::read_multi_range_first_internal(
} else {
#endif
conn->need_mon = &need_mons[roop_count];
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;
if ((error_num = spider_db_set_names(this, conn,
roop_count)))
{
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);
@ -4742,6 +4822,8 @@ int ha_spider::read_multi_range_first_internal(
result_list.quick_mode,
&need_mons[roop_count])
) {
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;
error_num = spider_db_errorno(conn);
@ -4770,6 +4852,8 @@ int ha_spider::read_multi_range_first_internal(
if (!error_num)
{
connection_ids[roop_count] = conn->connection_id;
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;
if (roop_count == link_ok)
@ -5463,6 +5547,7 @@ int ha_spider::read_multi_range_first_internal(
}
#endif
spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id];
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
{
pthread_mutex_lock(&conn->mta_conn_mutex);
@ -5471,6 +5556,11 @@ int ha_spider::read_multi_range_first_internal(
if ((error_num =
dbton_hdl->set_sql_for_exec(sql_type, roop_count)))
{
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
{
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
DBUG_RETURN(error_num);
}
if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
@ -5496,11 +5586,15 @@ int ha_spider::read_multi_range_first_internal(
} else {
#endif
conn->need_mon = &need_mons[roop_count];
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;
if ((error_num = spider_db_set_names(this, conn,
roop_count)))
{
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);
@ -5542,6 +5636,8 @@ int ha_spider::read_multi_range_first_internal(
-1,
&need_mons[roop_count])
) {
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;
error_num = spider_db_errorno(conn);
@ -5577,6 +5673,8 @@ int ha_spider::read_multi_range_first_internal(
result_list.quick_mode,
&need_mons[roop_count])
) {
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;
error_num = spider_db_errorno(conn);
@ -5603,6 +5701,8 @@ int ha_spider::read_multi_range_first_internal(
break;
}
connection_ids[roop_count] = conn->connection_id;
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;
if (roop_count == link_ok)
@ -6110,6 +6210,7 @@ int ha_spider::read_multi_range_next(
}
#endif
spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id];
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
{
pthread_mutex_lock(&conn->mta_conn_mutex);
@ -6118,6 +6219,11 @@ int ha_spider::read_multi_range_next(
if ((error_num =
dbton_hdl->set_sql_for_exec(sql_type, roop_count)))
{
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
{
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
DBUG_RETURN(error_num);
}
if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
@ -6142,11 +6248,15 @@ int ha_spider::read_multi_range_next(
} else {
#endif
conn->need_mon = &need_mons[roop_count];
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;
if ((error_num = spider_db_set_names(this, conn,
roop_count)))
{
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);
@ -6182,6 +6292,8 @@ int ha_spider::read_multi_range_next(
result_list.quick_mode,
&need_mons[roop_count])
) {
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;
error_num = spider_db_errorno(conn);
@ -6210,6 +6322,8 @@ int ha_spider::read_multi_range_next(
if (!error_num)
{
connection_ids[roop_count] = conn->connection_id;
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;
if (roop_count == link_ok)
@ -6907,6 +7021,7 @@ int ha_spider::read_multi_range_next(
}
#endif
spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id];
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
{
pthread_mutex_lock(&conn->mta_conn_mutex);
@ -6915,6 +7030,11 @@ int ha_spider::read_multi_range_next(
if ((error_num =
dbton_hdl->set_sql_for_exec(sql_type, roop_count)))
{
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
{
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
DBUG_RETURN(error_num);
}
if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
@ -6940,11 +7060,15 @@ int ha_spider::read_multi_range_next(
} else {
#endif
conn->need_mon = &need_mons[roop_count];
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;
if ((error_num = spider_db_set_names(this, conn,
roop_count)))
{
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);
@ -6986,6 +7110,8 @@ int ha_spider::read_multi_range_next(
-1,
&need_mons[roop_count])
) {
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;
error_num = spider_db_errorno(conn);
@ -7021,6 +7147,8 @@ int ha_spider::read_multi_range_next(
result_list.quick_mode,
&need_mons[roop_count])
) {
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;
error_num = spider_db_errorno(conn);
@ -7047,6 +7175,8 @@ int ha_spider::read_multi_range_next(
break;
}
connection_ids[roop_count] = conn->connection_id;
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;
if (roop_count == link_ok)
@ -7524,6 +7654,7 @@ int ha_spider::rnd_next_internal(
sql_type = SPIDER_SQL_TYPE_HANDLER;
}
spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id];
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
{
pthread_mutex_lock(&conn->mta_conn_mutex);
@ -7532,6 +7663,11 @@ int ha_spider::rnd_next_internal(
if ((error_num =
dbton_hdl->set_sql_for_exec(sql_type, roop_count)))
{
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
{
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
DBUG_RETURN(error_num);
}
if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
@ -7541,11 +7677,15 @@ int ha_spider::rnd_next_internal(
}
DBUG_PRINT("info",("spider sql_type=%lu", sql_type));
conn->need_mon = &need_mons[roop_count];
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;
if ((error_num = spider_db_set_names(this, conn,
roop_count)))
{
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);
@ -7580,6 +7720,8 @@ int ha_spider::rnd_next_internal(
result_list.quick_mode,
&need_mons[roop_count])
) {
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;
error_num = spider_db_errorno(conn);
@ -7606,6 +7748,8 @@ int ha_spider::rnd_next_internal(
DBUG_RETURN(check_error_mode_eof(error_num));
}
connection_ids[roop_count] = conn->connection_id;
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;
if (roop_count == link_ok)
@ -8116,6 +8260,7 @@ int ha_spider::ft_read_internal(
uint dbton_id = share->use_sql_dbton_ids[roop_count];
spider_db_handler *dbton_hdl = dbton_handler[dbton_id];
SPIDER_CONN *conn = conns[roop_count];
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
if (dbton_hdl->need_lock_before_set_sql_for_exec(
SPIDER_SQL_TYPE_SELECT_SQL))
{
@ -8125,6 +8270,12 @@ int ha_spider::ft_read_internal(
if ((error_num = dbton_hdl->set_sql_for_exec(
SPIDER_SQL_TYPE_SELECT_SQL, roop_count)))
{
if (dbton_hdl->need_lock_before_set_sql_for_exec(
SPIDER_SQL_TYPE_SELECT_SQL))
{
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
DBUG_RETURN(error_num);
}
if (!dbton_hdl->need_lock_before_set_sql_for_exec(
@ -8134,10 +8285,14 @@ int ha_spider::ft_read_internal(
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
}
conn->need_mon = &need_mons[roop_count];
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;
if ((error_num = spider_db_set_names(this, conn, roop_count)))
{
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);
@ -8171,6 +8326,8 @@ int ha_spider::ft_read_internal(
result_list.quick_mode,
&need_mons[roop_count])
) {
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;
error_num = spider_db_errorno(conn);
@ -8197,6 +8354,8 @@ int ha_spider::ft_read_internal(
DBUG_RETURN(check_error_mode_eof(error_num));
}
connection_ids[roop_count] = conn->connection_id;
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;
if (roop_count == link_ok)
@ -10455,9 +10614,12 @@ void ha_spider::bulk_req_exec()
if (conn->bulk_access_requests)
{
spider_bg_conn_wait(conn);
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 = &need_mon;
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;
/* currently only used for HS */
@ -10475,6 +10637,8 @@ void ha_spider::bulk_req_exec()
conn->bulk_access_sended += conn->bulk_access_requests;
*/
conn->bulk_access_requests = 0;
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);
@ -12217,6 +12381,7 @@ int ha_spider::drop_tmp_tables()
uint dbton_id = share->use_sql_dbton_ids[roop_count];
spider_db_handler *dbton_hdl = dbton_handler[dbton_id];
SPIDER_CONN *conn = conns[roop_count];
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
if (dbton_hdl->need_lock_before_set_sql_for_exec(
SPIDER_SQL_TYPE_TMP_SQL))
{
@ -12226,6 +12391,12 @@ int ha_spider::drop_tmp_tables()
if ((error_num = dbton_hdl->set_sql_for_exec(
SPIDER_SQL_TYPE_TMP_SQL, roop_count)))
{
if (dbton_hdl->need_lock_before_set_sql_for_exec(
SPIDER_SQL_TYPE_TMP_SQL))
{
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
DBUG_RETURN(error_num);
}
if (!dbton_hdl->need_lock_before_set_sql_for_exec(
@ -12235,10 +12406,14 @@ int ha_spider::drop_tmp_tables()
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
}
conn->need_mon = &need_mon;
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;
if ((tmp_error_num = spider_db_set_names(this, conn, roop_count)))
{
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);
@ -12275,6 +12450,8 @@ int ha_spider::drop_tmp_tables()
-1,
&need_mons[roop_count])
) {
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;
tmp_error_num = spider_db_errorno(conn);
@ -12300,6 +12477,8 @@ int ha_spider::drop_tmp_tables()
}
error_num = tmp_error_num;
} else {
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);

View file

@ -2385,6 +2385,7 @@ void *spider_bg_conn_action(
sql_type = SPIDER_SQL_TYPE_SELECT_HS;
}
#endif
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
if (dbton_handler->need_lock_before_set_sql_for_exec(sql_type))
{
pthread_mutex_lock(&conn->mta_conn_mutex);
@ -2414,6 +2415,8 @@ void *spider_bg_conn_action(
if (!result_list->bgs_error)
{
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;
#ifdef HA_CAN_BULK_ACCESS
@ -2491,6 +2494,8 @@ void *spider_bg_conn_action(
#ifdef HA_CAN_BULK_ACCESS
}
#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_unlock_later = FALSE;
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
@ -2501,11 +2506,14 @@ void *spider_bg_conn_action(
}
} else {
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;
result_list->bgs_error =
spider_db_store_result(spider, conn->link_idx, result_list->table);
if ((result_list->bgs_error_with_message = thd->is_error()))
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->bg_search = FALSE;
@ -2569,12 +2577,26 @@ void *spider_bg_conn_action(
{
DBUG_PRINT("info",("spider bg exec sql start"));
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_sql_type,
spider,
conn,
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;
continue;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -17,6 +17,8 @@
#define SPIDER_HEX_VERSION 0x0302
#if MYSQL_VERSION_ID < 50500
#define pthread_mutex_assert_owner(A)
#define pthread_mutex_assert_not_owner(A)
#else
#define my_free(A,B) my_free(A)
#ifdef pthread_mutex_t
@ -39,6 +41,8 @@
#undef pthread_mutex_destroy
#endif
#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
#undef pthread_cond_t
#endif

View file

@ -5815,13 +5815,18 @@ int spider_open_all_tables(
}
conn->error_mode &= spider_param_error_read_mode(thd, 0);
conn->error_mode &= spider_param_error_write_mode(thd, 0);
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 = &mon_val;
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;
if ((error_num = spider_db_before_query(conn, &mon_val)))
{
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);
@ -5834,6 +5839,8 @@ int spider_open_all_tables(
free_root(&mem_root, MYF(0));
DBUG_RETURN(error_num);
}
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);