summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKentoku SHIBA <kentokushiba@gmail.com>2020-09-04 22:10:57 +0900
committerKentoku <kentokushiba@gmail.com>2020-09-07 00:26:48 +0900
commit474ac593cee49f2c14bdaf4adf8f3a02dcd7600c (patch)
tree2492ff97b0aee1cc9b057e87b650683244d7ad82
parentc5cb59ce7741d3a6187c4dd01a80ed2f3670db67 (diff)
downloadmariadb-git-bb-10.3-MDEV-7098.tar.gz
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 671bb-10.3-MDEV-7098
-rw-r--r--storage/spider/ha_spider.cc179
-rw-r--r--storage/spider/spd_conn.cc22
-rw-r--r--storage/spider/spd_db_conn.cc823
-rw-r--r--storage/spider/spd_db_mysql.cc623
-rw-r--r--storage/spider/spd_db_oracle.cc492
-rw-r--r--storage/spider/spd_group_by_handler.cc15
-rw-r--r--storage/spider/spd_include.h4
-rw-r--r--storage/spider/spd_table.cc7
8 files changed, 1622 insertions, 543 deletions
diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc
index 967d2c6e5de..2b993fa7e9c 100644
--- a/storage/spider/ha_spider.cc
+++ b/storage/spider/ha_spider.cc
@@ -2331,6 +2331,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);
@@ -2338,6 +2339,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))
@@ -2359,11 +2365,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);
@@ -2399,6 +2409,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);
@@ -2426,6 +2438,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)
@@ -2827,6 +2841,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);
@@ -2834,6 +2849,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))
@@ -2852,11 +2872,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);
@@ -2892,6 +2916,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);
@@ -2919,6 +2945,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)
@@ -3297,6 +3325,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);
@@ -3305,6 +3334,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))
@@ -3323,11 +3357,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);
@@ -3363,6 +3401,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);
@@ -3390,6 +3430,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)
@@ -3685,6 +3727,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);
@@ -3693,6 +3736,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))
@@ -3711,11 +3759,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);
@@ -3751,6 +3803,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);
@@ -3778,6 +3832,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)
@@ -4133,6 +4189,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);
@@ -4140,6 +4197,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))
@@ -4158,11 +4220,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);
@@ -4198,6 +4264,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);
@@ -4225,6 +4293,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)
@@ -4763,6 +4833,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);
@@ -4771,6 +4842,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))
@@ -4795,11 +4871,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);
@@ -4836,6 +4916,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);
@@ -4865,6 +4947,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)
@@ -5560,6 +5644,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);
@@ -5568,6 +5653,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))
@@ -5593,11 +5683,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);
@@ -5640,6 +5734,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);
@@ -5676,6 +5772,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);
@@ -5703,6 +5801,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)
@@ -6212,6 +6312,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);
@@ -6220,6 +6321,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))
@@ -6244,11 +6350,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);
@@ -6285,6 +6395,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);
@@ -6314,6 +6426,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)
@@ -7013,6 +7127,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);
@@ -7021,6 +7136,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))
@@ -7046,11 +7166,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);
@@ -7093,6 +7217,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);
@@ -7129,6 +7255,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);
@@ -7156,6 +7284,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)
@@ -7675,6 +7805,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);
@@ -7683,6 +7814,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))
@@ -7692,11 +7828,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);
@@ -7732,6 +7872,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);
@@ -7759,6 +7901,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)
@@ -8291,6 +8435,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))
{
@@ -8300,6 +8445,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(
@@ -8309,10 +8460,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);
@@ -8347,6 +8502,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);
@@ -8374,6 +8531,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)
@@ -11135,9 +11294,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 */
@@ -11155,6 +11317,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);
@@ -12970,6 +13134,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))
{
@@ -12979,6 +13144,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(
@@ -12988,10 +13159,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);
@@ -13029,6 +13204,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);
@@ -13055,6 +13232,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);
diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc
index 4a8de844ca9..e7e48b40add 100644
--- a/storage/spider/spd_conn.cc
+++ b/storage/spider/spd_conn.cc
@@ -2594,6 +2594,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);
@@ -2634,6 +2635,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
@@ -2711,6 +2714,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);
@@ -2721,11 +2726,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;
@@ -2789,12 +2797,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;
}
diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc
index bf576f2359e..e87321f896d 100644
--- a/storage/spider/spd_db_conn.cc
+++ b/storage/spider/spd_db_conn.cc
@@ -213,22 +213,13 @@ int spider_db_ping_internal(
) {
int error_num;
DBUG_ENTER("spider_db_ping_internal");
- if (!conn->mta_conn_mutex_lock_already)
- {
- pthread_mutex_lock(&conn->mta_conn_mutex);
- SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
- conn->need_mon = need_mon;
- }
+ pthread_mutex_assert_owner(&conn->mta_conn_mutex);
DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name);
if (conn->server_lost || conn->queued_connect)
{
if ((error_num = spider_db_connect(share, conn, all_link_idx)))
{
- if (!conn->mta_conn_mutex_unlock_later)
- {
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- }
+ pthread_mutex_assert_owner(&conn->mta_conn_mutex);
DBUG_RETURN(error_num);
}
conn->server_lost = FALSE;
@@ -241,11 +232,7 @@ int spider_db_ping_internal(
{
DBUG_PRINT("info", ("spider conn=%p SERVER_LOST", conn));
conn->server_lost = TRUE;
- if (!conn->mta_conn_mutex_unlock_later)
- {
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- }
+ pthread_mutex_assert_owner(&conn->mta_conn_mutex);
DBUG_RETURN(error_num);
}
if((error_num = conn->db_conn->ping()))
@@ -253,20 +240,12 @@ int spider_db_ping_internal(
spider_db_disconnect(conn);
DBUG_PRINT("info", ("spider conn=%p SERVER_LOST", conn));
conn->server_lost = TRUE;
- if (!conn->mta_conn_mutex_unlock_later)
- {
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- }
+ pthread_mutex_assert_owner(&conn->mta_conn_mutex);
DBUG_RETURN(error_num);
}
}
conn->ping_time = (time_t) time((time_t*) 0);
- if (!conn->mta_conn_mutex_unlock_later)
- {
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- }
+ pthread_mutex_assert_owner(&conn->mta_conn_mutex);
DBUG_RETURN(0);
}
@@ -321,6 +300,7 @@ int spider_db_conn_queue_action(
conn->queued_connect = FALSE;
}
+ pthread_mutex_assert_owner(&conn->mta_conn_mutex);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL)
{
@@ -569,7 +549,6 @@ int spider_db_before_query(
int *need_mon
) {
int error_num;
- bool tmp_mta_conn_mutex_lock_already;
DBUG_ENTER("spider_db_before_query");
DBUG_ASSERT(need_mon);
#ifndef WITHOUT_SPIDER_BG_SEARCH
@@ -577,25 +556,18 @@ int spider_db_before_query(
spider_bg_conn_break(conn, NULL);
#endif
conn->in_before_query = TRUE;
- if (!conn->mta_conn_mutex_lock_already)
- {
- pthread_mutex_lock(&conn->mta_conn_mutex);
- SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
- conn->need_mon = need_mon;
- }
+ pthread_mutex_assert_owner(&conn->mta_conn_mutex);
DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name);
- tmp_mta_conn_mutex_lock_already = conn->mta_conn_mutex_lock_already;
- conn->mta_conn_mutex_lock_already = TRUE;
if ((error_num = spider_db_conn_queue_action(conn)))
{
conn->in_before_query = FALSE;
- conn->mta_conn_mutex_lock_already = tmp_mta_conn_mutex_lock_already;
+ pthread_mutex_assert_owner(&conn->mta_conn_mutex);
DBUG_RETURN(error_num);
}
- conn->mta_conn_mutex_lock_already = tmp_mta_conn_mutex_lock_already;
if (conn->server_lost)
{
conn->in_before_query = FALSE;
+ pthread_mutex_assert_owner(&conn->mta_conn_mutex);
DBUG_RETURN(CR_SERVER_GONE_ERROR);
}
DBUG_PRINT("info", ("spider conn[%p]->quick_target=%p",
@@ -622,6 +594,7 @@ int spider_db_before_query(
) {
conn->mta_conn_mutex_unlock_later = tmp_mta_conn_mutex_unlock_later;
conn->in_before_query = FALSE;
+ pthread_mutex_assert_owner(&conn->mta_conn_mutex);
DBUG_RETURN(error_num);
}
}
@@ -637,6 +610,7 @@ int spider_db_before_query(
}
}
conn->in_before_query = FALSE;
+ pthread_mutex_assert_owner(&conn->mta_conn_mutex);
DBUG_RETURN(0);
}
@@ -649,6 +623,7 @@ int spider_db_query(
) {
int error_num;
DBUG_ENTER("spider_db_query");
+ pthread_mutex_assert_owner(&conn->mta_conn_mutex);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL)
{
@@ -691,6 +666,7 @@ int spider_db_errorno(
int error_num;
DBUG_ENTER("spider_db_errorno");
DBUG_ASSERT(conn->need_mon);
+ pthread_mutex_assert_owner(&conn->mta_conn_mutex);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL)
{
@@ -705,6 +681,7 @@ int spider_db_errorno(
}
if (!conn->mta_conn_mutex_unlock_later)
{
+ DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
@@ -726,6 +703,7 @@ int spider_db_errorno(
}
if (!conn->mta_conn_mutex_unlock_later)
{
+ DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
@@ -738,6 +716,7 @@ int spider_db_errorno(
conn->error_length = strlen(conn->error_str);
if (!conn->mta_conn_mutex_unlock_later)
{
+ DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
@@ -763,6 +742,7 @@ int spider_db_errorno(
}
if (!conn->mta_conn_mutex_unlock_later)
{
+ DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
@@ -784,6 +764,7 @@ int spider_db_errorno(
}
if (!conn->mta_conn_mutex_unlock_later)
{
+ DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
@@ -800,6 +781,7 @@ int spider_db_errorno(
conn->server_lost = TRUE;
if (!conn->mta_conn_mutex_unlock_later)
{
+ DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
@@ -809,6 +791,7 @@ int spider_db_errorno(
*conn->need_mon = 0;
if (!conn->mta_conn_mutex_unlock_later)
{
+ DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
@@ -831,6 +814,7 @@ int spider_db_errorno(
*conn->need_mon = ER_SPIDER_HS_NUM;
if (!conn->mta_conn_mutex_unlock_later)
{
+ DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
@@ -839,6 +823,7 @@ int spider_db_errorno(
#endif
if (!conn->mta_conn_mutex_unlock_later)
{
+ DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
@@ -861,33 +846,25 @@ int spider_db_set_names_internal(
int all_link_idx,
int *need_mon
) {
- bool tmp_mta_conn_mutex_lock_already;
DBUG_ENTER("spider_db_set_names_internal");
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL)
{
#endif
- if (!conn->mta_conn_mutex_lock_already)
- {
- pthread_mutex_lock(&conn->mta_conn_mutex);
- SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
- conn->need_mon = need_mon;
- }
+ pthread_mutex_assert_owner(&conn->mta_conn_mutex);
DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name);
+ DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
+ DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
if (
!conn->access_charset ||
share->access_charset->cset != conn->access_charset->cset
) {
- tmp_mta_conn_mutex_lock_already = conn->mta_conn_mutex_lock_already;
- conn->mta_conn_mutex_lock_already = TRUE;
if (
spider_db_before_query(conn, need_mon) ||
conn->db_conn->set_character_set(share->access_charset->csname)
) {
- conn->mta_conn_mutex_lock_already = tmp_mta_conn_mutex_lock_already;
DBUG_RETURN(spider_db_errorno(conn));
}
- conn->mta_conn_mutex_lock_already = tmp_mta_conn_mutex_lock_already;
conn->access_charset = share->access_charset;
}
if (
@@ -902,13 +879,10 @@ int spider_db_set_names_internal(
) {
DBUG_PRINT("info",("spider all_link_idx=%d db=%s", all_link_idx,
share->tgt_dbs[all_link_idx]));
- tmp_mta_conn_mutex_lock_already = conn->mta_conn_mutex_lock_already;
- conn->mta_conn_mutex_lock_already = TRUE;
if (
spider_db_before_query(conn, need_mon) ||
conn->db_conn->select_db(share->tgt_dbs[all_link_idx])
) {
- conn->mta_conn_mutex_lock_already = tmp_mta_conn_mutex_lock_already;
DBUG_RETURN(spider_db_errorno(conn));
}
conn->default_database.length(0);
@@ -918,12 +892,6 @@ int spider_db_set_names_internal(
conn->default_database.q_append(share->tgt_dbs[all_link_idx],
share->tgt_dbs_lengths[all_link_idx] + 1);
conn->default_database.length(share->tgt_dbs_lengths[all_link_idx]);
- conn->mta_conn_mutex_lock_already = tmp_mta_conn_mutex_lock_already;
- }
- if (!conn->mta_conn_mutex_unlock_later)
- {
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
}
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
}
@@ -952,19 +920,11 @@ int spider_db_query_with_set_names(
spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id];
DBUG_ENTER("spider_db_query_with_set_names");
-/*
- pthread_mutex_lock(&conn->mta_conn_mutex);
- SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
-*/
- conn->need_mon = &spider->need_mons[link_idx];
- conn->mta_conn_mutex_lock_already = TRUE;
- conn->mta_conn_mutex_unlock_later = TRUE;
+ pthread_mutex_assert_owner(&conn->mta_conn_mutex);
+ DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
+ DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
if ((error_num = spider_db_set_names(spider, conn, link_idx)))
{
- 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);
if (
share->monitoring_kind[link_idx] &&
spider->need_mons[link_idx]
@@ -996,8 +956,6 @@ int spider_db_query_with_set_names(
-1,
&spider->need_mons[link_idx])
) {
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
error_num = spider_db_errorno(conn);
if (
share->monitoring_kind[link_idx] &&
@@ -1022,10 +980,6 @@ int spider_db_query_with_set_names(
}
DBUG_RETURN(error_num);
}
- 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);
DBUG_RETURN(0);
}
@@ -1039,15 +993,16 @@ int spider_db_query_for_bulk_update(
SPIDER_SHARE *share = spider->share;
DBUG_ENTER("spider_db_query_for_bulk_update");
-/*
- pthread_mutex_lock(&conn->mta_conn_mutex);
- SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
-*/
+ pthread_mutex_assert_owner(&conn->mta_conn_mutex);
conn->need_mon = &spider->need_mons[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;
if ((error_num = spider_db_set_names(spider, 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);
@@ -1084,6 +1039,8 @@ int spider_db_query_for_bulk_update(
-1,
&spider->need_mons[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;
error_num = spider_db_errorno(conn);
@@ -1131,6 +1088,8 @@ int spider_db_query_for_bulk_update(
}
if (error_num > 0 && !conn->db_conn->is_dup_entry_error(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);
@@ -1158,6 +1117,8 @@ int spider_db_query_for_bulk_update(
}
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);
@@ -3751,6 +3712,7 @@ int spider_db_store_result(
ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0));
if (!conn->mta_conn_mutex_unlock_later)
{
+ DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
@@ -3767,6 +3729,7 @@ int spider_db_store_result(
) {
if (!conn->mta_conn_mutex_unlock_later)
{
+ DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
@@ -3798,6 +3761,7 @@ int spider_db_store_result(
) {
if (!conn->mta_conn_mutex_unlock_later)
{
+ DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
@@ -3841,6 +3805,7 @@ int spider_db_store_result(
) {
if (!conn->mta_conn_mutex_unlock_later)
{
+ DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
@@ -3880,6 +3845,7 @@ int spider_db_store_result(
{
if (!conn->mta_conn_mutex_unlock_later)
{
+ DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
@@ -3908,6 +3874,7 @@ int spider_db_store_result(
#endif
if (!conn->mta_conn_mutex_unlock_later && !call_db_errorno)
{
+ DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
@@ -3915,6 +3882,7 @@ int spider_db_store_result(
} else {
if (!conn->mta_conn_mutex_unlock_later)
{
+ DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
@@ -3958,6 +3926,7 @@ int spider_db_store_result(
result_list->limit_num -= current->prev->record_num;
if (!conn->mta_conn_mutex_unlock_later)
{
+ DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
@@ -3981,6 +3950,7 @@ int spider_db_store_result(
} else {
if (!conn->mta_conn_mutex_unlock_later)
{
+ DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
@@ -3992,6 +3962,7 @@ int spider_db_store_result(
spider->quick_targets[link_idx] = spider;
if (!conn->mta_conn_mutex_unlock_later)
{
+ DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
@@ -4222,6 +4193,7 @@ int spider_db_store_result(
ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0));
if (!conn->mta_conn_mutex_unlock_later)
{
+ DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
@@ -4247,6 +4219,7 @@ int spider_db_store_result(
} else {
if (!conn->mta_conn_mutex_unlock_later)
{
+ DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
@@ -4257,6 +4230,7 @@ int spider_db_store_result(
result_list->hs_has_result = TRUE;
if (!conn->mta_conn_mutex_unlock_later)
{
+ DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
}
@@ -4342,15 +4316,15 @@ int spider_db_bulk_store_result(
error_num = spider_db_bulk_open_handler(spider, conn, link_idx);
if (!discard_result)
{
- bool tmp_mta_conn_mutex_unlock_later;
- tmp_mta_conn_mutex_unlock_later = conn->mta_conn_mutex_unlock_later;
+ pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
+ DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later);
conn->mta_conn_mutex_unlock_later = TRUE;
if ((tmp_error_num = spider_db_store_result(spider, link_idx,
spider->get_table())))
{
error_num = tmp_error_num;
}
- conn->mta_conn_mutex_unlock_later = tmp_mta_conn_mutex_unlock_later;
+ conn->mta_conn_mutex_unlock_later = FALSE;
} else {
if (spider->connection_ids[link_idx] == conn->connection_id)
spider_db_discard_result(spider, link_idx, conn);
@@ -4579,6 +4553,7 @@ int spider_db_seek_next(
link_idx = link_idx_holder->link_idx;
spider_db_handler *dbton_handler =
spider->dbton_handler[conn->dbton_id];
+ 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);
@@ -4587,6 +4562,11 @@ int spider_db_seek_next(
if ((error_num = dbton_handler->set_sql_for_exec(sql_type,
link_idx)))
{
+ if (dbton_handler->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_PRINT("info",("spider error_num 6=%d", error_num));
DBUG_RETURN(error_num);
}
@@ -4596,10 +4576,14 @@ int spider_db_seek_next(
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
}
conn->need_mon = &spider->need_mons[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;
if ((error_num = spider_db_set_names(spider, 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);
@@ -4620,6 +4604,8 @@ int spider_db_seek_next(
result_list->quick_mode,
&spider->need_mons[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;
error_num = spider_db_errorno(conn);
@@ -4632,6 +4618,8 @@ int spider_db_seek_next(
DBUG_RETURN(error_num);
}
spider->connection_ids[link_idx] = 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 (fields->is_first_link_ok_chain(link_idx_chain))
@@ -4673,6 +4661,7 @@ int spider_db_seek_next(
}
spider_db_handler *dbton_handler =
spider->dbton_handler[conn->dbton_id];
+ 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);
@@ -4681,6 +4670,11 @@ int spider_db_seek_next(
if ((error_num = dbton_handler->set_sql_for_exec(sql_type,
roop_count)))
{
+ if (dbton_handler->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_PRINT("info",("spider error_num 6=%d", error_num));
DBUG_RETURN(error_num);
}
@@ -4690,10 +4684,14 @@ int spider_db_seek_next(
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
}
conn->need_mon = &spider->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(spider, 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);
@@ -4730,6 +4728,8 @@ int spider_db_seek_next(
result_list->quick_mode,
&spider->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);
@@ -4758,6 +4758,8 @@ int spider_db_seek_next(
DBUG_RETURN(error_num);
}
spider->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)
@@ -4802,6 +4804,8 @@ int spider_db_seek_next(
#endif
} else {
spider->connection_ids[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;
if ((error_num = spider_db_store_result(spider, link_idx, table)))
{
@@ -4928,6 +4932,7 @@ int spider_db_seek_last(
}
conn = spider->conns[roop_count];
spider_db_handler *dbton_handler = spider->dbton_handler[conn->dbton_id];
+ 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);
@@ -4935,6 +4940,11 @@ int spider_db_seek_last(
}
if ((error_num = dbton_handler->set_sql_for_exec(sql_type, roop_count)))
{
+ if (dbton_handler->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_handler->need_lock_before_set_sql_for_exec(sql_type))
@@ -4944,10 +4954,14 @@ int spider_db_seek_last(
}
DBUG_PRINT("info",("spider sql_type=%lu", sql_type));
conn->need_mon = &spider->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(spider, 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);
@@ -4983,6 +4997,8 @@ int spider_db_seek_last(
result_list->quick_mode,
&spider->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);
@@ -5010,6 +5026,8 @@ int spider_db_seek_last(
DBUG_RETURN(error_num);
}
spider->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)
@@ -5131,6 +5149,7 @@ int spider_db_seek_last(
}
conn = spider->conns[roop_count];
spider_db_handler *dbton_handler = spider->dbton_handler[conn->dbton_id];
+ 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);
@@ -5138,6 +5157,11 @@ int spider_db_seek_last(
}
if ((error_num = dbton_handler->set_sql_for_exec(sql_type, roop_count)))
{
+ if (dbton_handler->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_handler->need_lock_before_set_sql_for_exec(sql_type))
@@ -5147,10 +5171,14 @@ int spider_db_seek_last(
}
DBUG_PRINT("info",("spider sql_type=%lu", sql_type));
conn->need_mon = &spider->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(spider, 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);
@@ -5186,6 +5214,8 @@ int spider_db_seek_last(
result_list->quick_mode,
&spider->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);
@@ -5213,6 +5243,8 @@ int spider_db_seek_last(
DBUG_RETURN(error_num);
}
spider->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)
@@ -5886,8 +5918,6 @@ int spider_db_bulk_insert(
#endif
SPIDER_SHARE *share = spider->share;
THD *thd = spider->trx->thd;
- bool mta_conn_mutex_lock_already_backup;
- bool mta_conn_mutex_unlock_later_backup;
DBUG_ENTER("spider_db_bulk_insert");
if (!bulk_end)
@@ -5942,61 +5972,50 @@ int spider_db_bulk_insert(
sql_type = SPIDER_SQL_TYPE_INSERT_SQL;
conn = spider->conns[roop_count2];
dbton_handler = spider->dbton_handler[conn->dbton_id];
- mta_conn_mutex_lock_already_backup =
- conn->mta_conn_mutex_lock_already;
- mta_conn_mutex_unlock_later_backup =
- conn->mta_conn_mutex_unlock_later;
+ pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
if (dbton_handler->need_lock_before_set_sql_for_exec(sql_type))
{
- if (!mta_conn_mutex_lock_already_backup)
- {
- pthread_mutex_lock(&conn->mta_conn_mutex);
- SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
- }
+ pthread_mutex_lock(&conn->mta_conn_mutex);
+ SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
}
if ((error_num = dbton_handler->set_sql_for_exec(sql_type,
roop_count2)))
{
+ if (dbton_handler->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_handler->need_lock_before_set_sql_for_exec(sql_type))
{
- if (!mta_conn_mutex_lock_already_backup)
- {
- pthread_mutex_lock(&conn->mta_conn_mutex);
- SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
- }
+ pthread_mutex_lock(&conn->mta_conn_mutex);
+ SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
}
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
} else {
sql_type = SPIDER_SQL_TYPE_INSERT_HS;
conn = spider->hs_w_conns[roop_count2];
dbton_handler = spider->dbton_handler[conn->dbton_id];
- mta_conn_mutex_lock_already_backup =
- conn->mta_conn_mutex_lock_already;
- mta_conn_mutex_unlock_later_backup =
- conn->mta_conn_mutex_unlock_later;
- if (!mta_conn_mutex_lock_already_backup)
- {
- pthread_mutex_lock(&conn->mta_conn_mutex);
- SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
- }
+ 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);
}
#endif
conn->need_mon = &spider->need_mons[roop_count2];
+ 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(spider, conn, roop_count2)))
{
- conn->mta_conn_mutex_lock_already =
- mta_conn_mutex_lock_already_backup;
- conn->mta_conn_mutex_unlock_later =
- mta_conn_mutex_unlock_later_backup;
- if (!mta_conn_mutex_unlock_later_backup)
- {
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- }
+ 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);
if (
share->monitoring_kind[roop_count2] &&
spider->need_mons[roop_count2]
@@ -6035,15 +6054,12 @@ int spider_db_bulk_insert(
{
conn->db_conn->set_dup_key_idx(spider, roop_count2);
}
- conn->mta_conn_mutex_lock_already =
- mta_conn_mutex_lock_already_backup;
- conn->mta_conn_mutex_unlock_later =
- mta_conn_mutex_unlock_later_backup;
- if (!mta_conn_mutex_unlock_later_backup)
- {
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- }
+ 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);
if (
error_num != ER_DUP_ENTRY &&
error_num != ER_DUP_KEY &&
@@ -6070,8 +6086,10 @@ int spider_db_bulk_insert(
}
DBUG_RETURN(error_num);
}
- conn->mta_conn_mutex_lock_already = mta_conn_mutex_lock_already_backup;
- conn->mta_conn_mutex_unlock_later = mta_conn_mutex_unlock_later_backup;
+ 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 defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (conn->conn_kind != SPIDER_CONN_KIND_MYSQL)
{
@@ -6107,11 +6125,8 @@ int spider_db_bulk_insert(
}
}
#endif
- if (!mta_conn_mutex_unlock_later_backup)
- {
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- }
+ SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
+ pthread_mutex_unlock(&conn->mta_conn_mutex);
if (first_insert_link_idx == -1)
{
first_insert_link_idx = roop_count2;
@@ -6120,14 +6135,12 @@ int spider_db_bulk_insert(
}
conn = first_insert_conn;
- mta_conn_mutex_lock_already_backup = conn->mta_conn_mutex_lock_already;
- mta_conn_mutex_unlock_later_backup = conn->mta_conn_mutex_unlock_later;
- if (!mta_conn_mutex_lock_already_backup)
- {
- pthread_mutex_lock(&conn->mta_conn_mutex);
- SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
- }
+ 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[first_insert_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;
if (spider->sql_kinds & SPIDER_SQL_KIND_SQL)
@@ -6149,15 +6162,12 @@ int spider_db_bulk_insert(
else if ((error_num = dbton_handler->
show_last_insert_id(first_insert_link_idx, last_insert_id)))
{
- conn->mta_conn_mutex_lock_already =
- mta_conn_mutex_lock_already_backup;
- conn->mta_conn_mutex_unlock_later =
- mta_conn_mutex_unlock_later_backup;
- if (!mta_conn_mutex_unlock_later_backup)
- {
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- }
+ 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);
DBUG_RETURN(error_num);
}
table->next_number_field->set_notnull();
@@ -6167,25 +6177,21 @@ int spider_db_bulk_insert(
(error_num = table->next_number_field->store(
last_insert_id, TRUE))
) {
- conn->mta_conn_mutex_lock_already =
- mta_conn_mutex_lock_already_backup;
- conn->mta_conn_mutex_unlock_later =
- mta_conn_mutex_unlock_later_backup;
- if (!mta_conn_mutex_unlock_later_backup)
- {
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- }
+ 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);
DBUG_RETURN(error_num);
}
}
- conn->mta_conn_mutex_lock_already = mta_conn_mutex_lock_already_backup;
- conn->mta_conn_mutex_unlock_later = mta_conn_mutex_unlock_later_backup;
- if (!mta_conn_mutex_unlock_later_backup)
- {
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- }
+ 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);
spider->store_last_insert_id = 0;
#ifdef HA_CAN_BULK_ACCESS
}
@@ -6229,8 +6235,11 @@ int spider_db_bulk_bulk_insert(
conn = spider->hs_w_conns[roop_count2];
}
#endif
+ 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);
+ 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_bulk_open_handler(spider, conn,
@@ -6238,6 +6247,8 @@ int spider_db_bulk_bulk_insert(
{
error_num = tmp_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;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
@@ -6286,9 +6297,12 @@ int spider_db_bulk_bulk_insert(
}
conn = first_insert_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 = &spider->need_mons[first_insert_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;
if (table->next_number_field &&
@@ -6315,6 +6329,8 @@ int spider_db_bulk_bulk_insert(
error_num = tmp_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);
@@ -6442,6 +6458,7 @@ int spider_db_bulk_update_size_limit(
) {
conn = spider->conns[roop_count];
spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id];
+ pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
if (dbton_hdl->need_lock_before_set_sql_for_exec(
SPIDER_SQL_TYPE_BULK_UPDATE_SQL))
{
@@ -6451,6 +6468,12 @@ int spider_db_bulk_update_size_limit(
if ((error_num = dbton_hdl->set_sql_for_exec(
SPIDER_SQL_TYPE_BULK_UPDATE_SQL, roop_count)))
{
+ if (dbton_hdl->need_lock_before_set_sql_for_exec(
+ SPIDER_SQL_TYPE_BULK_UPDATE_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(
@@ -6461,7 +6484,11 @@ int spider_db_bulk_update_size_limit(
}
if ((error_num = spider_db_query_for_bulk_update(
spider, conn, roop_count, &dup_key_found)))
+ {
+ pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
DBUG_RETURN(error_num);
+ }
+ pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
}
spider->reset_sql_sql(SPIDER_SQL_TYPE_BULK_UPDATE_SQL);
} else {
@@ -6527,6 +6554,7 @@ int spider_db_bulk_update_end(
) {
conn = spider->conns[roop_count];
spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id];
+ pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
if (dbton_hdl->need_lock_before_set_sql_for_exec(
SPIDER_SQL_TYPE_BULK_UPDATE_SQL))
{
@@ -6536,14 +6564,14 @@ int spider_db_bulk_update_end(
if ((error_num = dbton_hdl->set_sql_for_exec(
SPIDER_SQL_TYPE_BULK_UPDATE_SQL, roop_count)))
{
+ if (dbton_hdl->need_lock_before_set_sql_for_exec(
+ SPIDER_SQL_TYPE_BULK_UPDATE_SQL))
+ {
+ SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
+ pthread_mutex_unlock(&conn->mta_conn_mutex);
+ }
if (error_num == ER_SPIDER_COND_SKIP_NUM)
{
- if (dbton_hdl->need_lock_before_set_sql_for_exec(
- SPIDER_SQL_TYPE_BULK_UPDATE_SQL))
- {
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- }
continue;
}
DBUG_RETURN(error_num);
@@ -6556,7 +6584,11 @@ int spider_db_bulk_update_end(
}
if ((error_num = spider_db_query_for_bulk_update(
spider, conn, roop_count, dup_key_found)))
+ {
+ pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
goto error_query;
+ }
+ pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
}
}
if (error_num != HA_ERR_END_OF_FILE)
@@ -6581,6 +6613,7 @@ int spider_db_bulk_update_end(
) {
conn = spider->conns[roop_count];
spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id];
+ pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
if (dbton_hdl->need_lock_before_set_sql_for_exec(
SPIDER_SQL_TYPE_BULK_UPDATE_SQL))
{
@@ -6590,6 +6623,12 @@ int spider_db_bulk_update_end(
if ((error_num = dbton_hdl->set_sql_for_exec(
SPIDER_SQL_TYPE_BULK_UPDATE_SQL, roop_count)))
{
+ if (dbton_hdl->need_lock_before_set_sql_for_exec(
+ SPIDER_SQL_TYPE_BULK_UPDATE_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(
@@ -6600,7 +6639,11 @@ int spider_db_bulk_update_end(
}
if ((error_num = spider_db_query_for_bulk_update(
spider, conn, roop_count, dup_key_found)))
+ {
+ pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
goto error_last_query;
+ }
+ pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
}
}
}
@@ -6668,6 +6711,7 @@ int spider_db_update(
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000
conn->ignore_dup_key = spider->ignore_dup_key;
#endif
+ pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
if (dbton_hdl->need_lock_before_set_sql_for_exec(
SPIDER_SQL_TYPE_UPDATE_SQL))
{
@@ -6677,6 +6721,12 @@ int spider_db_update(
if ((error_num = dbton_hdl->set_sql_for_exec(
SPIDER_SQL_TYPE_UPDATE_SQL, roop_count)))
{
+ if (dbton_hdl->need_lock_before_set_sql_for_exec(
+ SPIDER_SQL_TYPE_UPDATE_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(
@@ -6686,10 +6736,14 @@ int spider_db_update(
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
}
conn->need_mon = &spider->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(spider, 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);
@@ -6725,6 +6779,8 @@ int spider_db_update(
-1,
&spider->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);
@@ -6764,6 +6820,8 @@ int spider_db_update(
if ((error_num = dbton_hdl->append_insert_for_recovery(
SPIDER_SQL_TYPE_INSERT_SQL, 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);
@@ -6778,6 +6836,8 @@ int spider_db_update(
-1,
&spider->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);
@@ -6808,6 +6868,8 @@ int spider_db_update(
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);
@@ -6997,6 +7059,7 @@ int spider_db_direct_update(
}
#endif
spider_db_handler *dbton_hdl = spider->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);
@@ -7004,6 +7067,11 @@ int spider_db_direct_update(
}
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))
@@ -7019,10 +7087,14 @@ int spider_db_direct_update(
} else {
#endif
conn->need_mon = &spider->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(spider, 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);
@@ -7061,6 +7133,8 @@ int spider_db_direct_update(
) &&
(error_num != HA_ERR_FOUND_DUPP_KEY || !spider->ignore_dup_key)
) {
+ 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);
@@ -7128,6 +7202,8 @@ int spider_db_direct_update(
{
error_num = spider_db_errorno(conn);
}
+ 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);
@@ -7136,11 +7212,13 @@ int spider_db_direct_update(
}
}
#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;
#ifdef HA_CAN_BULK_ACCESS
}
#endif
- 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);
}
@@ -7252,6 +7330,7 @@ int spider_db_direct_update(
conn = spider->conns[roop_count];
sql_type = SPIDER_SQL_TYPE_UPDATE_SQL;
spider_db_handler *dbton_hdl = spider->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);
@@ -7259,6 +7338,11 @@ int spider_db_direct_update(
}
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))
@@ -7274,10 +7358,14 @@ int spider_db_direct_update(
} else {
#endif
conn->need_mon = &spider->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(spider, 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);
@@ -7316,6 +7404,8 @@ int spider_db_direct_update(
) &&
(error_num != HA_ERR_FOUND_DUPP_KEY || !spider->ignore_dup_key)
) {
+ 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);
@@ -7351,11 +7441,13 @@ int spider_db_direct_update(
DBUG_PRINT("info", ("spider update_rows = %llu", *update_rows));
counted = TRUE;
}
+ 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;
#ifdef HA_CAN_BULK_ACCESS
}
#endif
- 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);
}
@@ -7396,8 +7488,11 @@ int spider_db_bulk_direct_update(
conn = spider->hs_w_conns[roop_count];
}
#endif
+ 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);
+ 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_bulk_open_handler(spider, conn,
@@ -7443,6 +7538,8 @@ int spider_db_bulk_direct_update(
{
error_num = spider_db_errorno(conn);
}
+ 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);
@@ -7451,6 +7548,8 @@ int spider_db_bulk_direct_update(
}
}
#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);
@@ -7507,6 +7606,7 @@ int spider_db_delete(
) {
conn = spider->conns[roop_count];
spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id];
+ pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
if (dbton_hdl->need_lock_before_set_sql_for_exec(
SPIDER_SQL_TYPE_DELETE_SQL))
{
@@ -7516,6 +7616,12 @@ int spider_db_delete(
if ((error_num = dbton_hdl->set_sql_for_exec(
SPIDER_SQL_TYPE_DELETE_SQL, roop_count)))
{
+ if (dbton_hdl->need_lock_before_set_sql_for_exec(
+ SPIDER_SQL_TYPE_DELETE_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(
@@ -7524,9 +7630,27 @@ int spider_db_delete(
pthread_mutex_lock(&conn->mta_conn_mutex);
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
}
+ 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_query_with_set_names(
SPIDER_SQL_TYPE_DELETE_SQL, spider, 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);
+ pthread_mutex_unlock(&conn->mta_conn_mutex);
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);
+ pthread_mutex_unlock(&conn->mta_conn_mutex);
result_list->update_sqls[roop_count].length(0);
}
if ((error_num = spider->reset_sql_sql(SPIDER_SQL_TYPE_DELETE_SQL)))
@@ -7639,6 +7763,7 @@ int spider_db_direct_delete(
}
#endif
spider_db_handler *dbton_hdl = spider->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);
@@ -7646,6 +7771,11 @@ int spider_db_direct_delete(
}
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))
@@ -7661,10 +7791,14 @@ int spider_db_direct_delete(
} else {
#endif
conn->need_mon = &spider->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(spider, 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);
@@ -7700,6 +7834,8 @@ int spider_db_direct_delete(
-1,
&spider->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);
@@ -7726,6 +7862,8 @@ int spider_db_direct_delete(
}
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;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
@@ -7861,6 +7999,7 @@ int spider_db_direct_delete(
conn = spider->conns[roop_count];
sql_type = SPIDER_SQL_TYPE_DELETE_SQL;
spider_db_handler *dbton_hdl = spider->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);
@@ -7868,6 +8007,11 @@ int spider_db_direct_delete(
}
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))
@@ -7883,10 +8027,14 @@ int spider_db_direct_delete(
} else {
#endif
conn->need_mon = &spider->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(spider, 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);
@@ -7922,6 +8070,8 @@ int spider_db_direct_delete(
-1,
&spider->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);
@@ -7948,6 +8098,8 @@ int spider_db_direct_delete(
}
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;
if (!counted)
@@ -7996,6 +8148,7 @@ int spider_db_delete_all_rows(
uint dbton_id = share->use_sql_dbton_ids[roop_count];
spider_db_handler *dbton_hdl = spider->dbton_handler[dbton_id];
conn = spider->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_DELETE_SQL))
{
@@ -8005,6 +8158,12 @@ int spider_db_delete_all_rows(
if ((error_num = dbton_hdl->set_sql_for_exec(
SPIDER_SQL_TYPE_DELETE_SQL, roop_count)))
{
+ if (dbton_hdl->need_lock_before_set_sql_for_exec(
+ SPIDER_SQL_TYPE_DELETE_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(
@@ -8014,6 +8173,8 @@ int spider_db_delete_all_rows(
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
}
conn->need_mon = &spider->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;
spider_conn_set_timeout_from_share(conn, roop_count, spider->trx->thd,
@@ -8036,6 +8197,8 @@ int spider_db_delete_all_rows(
/* retry */
if ((error_num = spider_db_ping(spider, 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);
@@ -8065,6 +8228,8 @@ int spider_db_delete_all_rows(
}
if ((error_num = spider_db_set_names(spider, 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);
@@ -8100,6 +8265,8 @@ int spider_db_delete_all_rows(
-1,
&spider->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);
@@ -8127,6 +8294,8 @@ int spider_db_delete_all_rows(
DBUG_RETURN(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);
@@ -8155,6 +8324,8 @@ int spider_db_delete_all_rows(
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);
@@ -9940,7 +10111,14 @@ int spider_db_udf_direct_sql(
c_thd->lex->sql_command = SQLCOM_INSERT;
#endif
+ 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;
if (
!(error_num = spider_db_udf_direct_sql_set_names(direct_sql, trx, conn)) &&
!(error_num = spider_db_udf_direct_sql_select_db(direct_sql, conn))
@@ -9963,9 +10141,6 @@ int spider_db_udf_direct_sql(
#endif
DBUG_RETURN(error_num);
}
- pthread_mutex_lock(&conn->mta_conn_mutex);
- SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
- DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name);
}
#endif
spider_conn_set_timeout_from_direct_sql(conn, thd, direct_sql);
@@ -9984,8 +10159,6 @@ int spider_db_udf_direct_sql(
DBUG_PRINT("info",("spider conn=%p", conn));
if (!direct_sql->table_count)
roop_count = -1;
- conn->mta_conn_mutex_lock_already = TRUE;
- conn->mta_conn_mutex_unlock_later = TRUE;
do {
if (roop_count == direct_sql->table_count)
{
@@ -10197,12 +10370,14 @@ int spider_db_udf_direct_sql(
if (roop_count >= 0)
roop_count++;
} while (status == 0);
- 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);
}
}
+ 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);
if (need_trx_end && insert_start)
{
if (error_num)
@@ -10232,19 +10407,13 @@ int spider_db_udf_direct_sql_select_db(
SPIDER_CONN *conn
) {
int error_num, need_mon = 0;
- bool tmp_mta_conn_mutex_lock_already;
SPIDER_DB_CONN *db_conn = conn->db_conn;
DBUG_ENTER("spider_db_udf_direct_sql_select_db");
+ pthread_mutex_assert_owner(&conn->mta_conn_mutex);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (direct_sql->access_mode == 0)
{
#endif
- if (!conn->mta_conn_mutex_lock_already)
- {
- 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_file_pos.file_name);
if (
!conn->default_database.length() ||
@@ -10253,8 +10422,6 @@ int spider_db_udf_direct_sql_select_db(
memcmp(direct_sql->tgt_default_db_name, conn->default_database.ptr(),
direct_sql->tgt_default_db_name_length)
) {
- tmp_mta_conn_mutex_lock_already = conn->mta_conn_mutex_lock_already;
- conn->mta_conn_mutex_lock_already = TRUE;
if (
(
spider_db_before_query(conn, &need_mon) ||
@@ -10268,7 +10435,6 @@ int spider_db_udf_direct_sql_select_db(
)
my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM,
ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0));
- conn->mta_conn_mutex_lock_already = tmp_mta_conn_mutex_lock_already;
DBUG_RETURN(error_num);
}
conn->default_database.length(0);
@@ -10278,12 +10444,6 @@ int spider_db_udf_direct_sql_select_db(
conn->default_database.q_append(direct_sql->tgt_default_db_name,
direct_sql->tgt_default_db_name_length + 1);
conn->default_database.length(direct_sql->tgt_default_db_name_length);
- conn->mta_conn_mutex_lock_already = tmp_mta_conn_mutex_lock_already;
- }
- if (!conn->mta_conn_mutex_unlock_later)
- {
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
}
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
}
@@ -10297,25 +10457,17 @@ int spider_db_udf_direct_sql_set_names(
SPIDER_CONN *conn
) {
int error_num, need_mon = 0;
- bool tmp_mta_conn_mutex_lock_already;
DBUG_ENTER("spider_db_udf_direct_sql_set_names");
+ pthread_mutex_assert_owner(&conn->mta_conn_mutex);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (direct_sql->access_mode == 0)
{
#endif
- if (!conn->mta_conn_mutex_lock_already)
- {
- 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_file_pos.file_name);
if (
!conn->access_charset ||
trx->udf_access_charset->cset != conn->access_charset->cset
) {
- tmp_mta_conn_mutex_lock_already = conn->mta_conn_mutex_lock_already;
- conn->mta_conn_mutex_lock_already = TRUE;
if (
(
spider_db_before_query(conn, &need_mon) ||
@@ -10330,17 +10482,10 @@ int spider_db_udf_direct_sql_set_names(
my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM,
ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0));
}
- conn->mta_conn_mutex_lock_already = tmp_mta_conn_mutex_lock_already;
DBUG_RETURN(error_num);
}
- conn->mta_conn_mutex_lock_already = tmp_mta_conn_mutex_lock_already;
conn->access_charset = trx->udf_access_charset;
}
- if (!conn->mta_conn_mutex_unlock_later)
- {
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- }
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
}
#endif
@@ -10404,13 +10549,18 @@ int spider_db_udf_ping_table(
spider.conn_link_idx = &tmp_conn_link_idx;
spider.db_request_phase = &db_request_phase;
spider.db_request_id = &db_request_id;
+ 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;
if ((error_num = spider_db_ping(&spider, conn, 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);
@@ -10426,6 +10576,8 @@ int spider_db_udf_ping_table(
share->server_names[0]);
DBUG_RETURN(ER_CONNECT_TO_FOREIGN_DATA_SOURCE);
}
+ 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);
@@ -10472,13 +10624,18 @@ int spider_db_udf_ping_table(
my_afree(sql_buf);
DBUG_RETURN(error_num);
}
+ 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;
if ((error_num = spider_db_set_names(&spider, conn, 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);
@@ -10497,6 +10654,8 @@ int spider_db_udf_ping_table(
-1,
&need_mon)
) {
+ 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);
@@ -10506,6 +10665,8 @@ int spider_db_udf_ping_table(
my_afree(sql_buf);
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_db_discard_result(&spider, 0, conn);
@@ -10711,13 +10872,18 @@ int spider_db_udf_ping_table_mon_next(
DBUG_RETURN(error_num);
}
+ 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;
if ((error_num = spider_db_ping(&spider, conn, 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);
@@ -10729,6 +10895,8 @@ int spider_db_udf_ping_table_mon_next(
}
if ((error_num = spider_db_set_names(&spider, conn, 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);
@@ -10744,6 +10912,8 @@ int spider_db_udf_ping_table_mon_next(
-1,
&need_mon)
) {
+ 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;
my_afree(sql_buf);
@@ -10757,9 +10927,18 @@ int spider_db_udf_ping_table_mon_next(
request_key.next = NULL;
if (!(res = conn->db_conn->store_result(NULL, &request_key, &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;
- if (error_num || (error_num = spider_db_errorno(conn)))
+ if (error_num)
+ {
+ SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
+ pthread_mutex_unlock(&conn->mta_conn_mutex);
+ my_afree(sql_buf);
+ DBUG_RETURN(error_num);
+ }
+ else if ((error_num = spider_db_errorno(conn)))
{
my_afree(sql_buf);
DBUG_RETURN(error_num);
@@ -10768,6 +10947,8 @@ int spider_db_udf_ping_table_mon_next(
my_afree(sql_buf);
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
}
+ 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);
@@ -10854,8 +11035,22 @@ int spider_db_udf_copy_tables(
spider_conn_clear_queue_at_commit(tmp_conn);
if (!tmp_conn->trx_start)
{
+ pthread_mutex_assert_not_owner(&tmp_conn->mta_conn_mutex);
+ pthread_mutex_lock(&tmp_conn->mta_conn_mutex);
+ SPIDER_SET_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos);
+ tmp_conn->need_mon = &tmp_spider->need_mons[0];
+ DBUG_ASSERT(!tmp_conn->mta_conn_mutex_lock_already);
+ DBUG_ASSERT(!tmp_conn->mta_conn_mutex_unlock_later);
+ tmp_conn->mta_conn_mutex_lock_already = TRUE;
+ tmp_conn->mta_conn_mutex_unlock_later = TRUE;
if (spider_db_ping(tmp_spider, tmp_conn, 0))
{
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already);
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later);
+ tmp_conn->mta_conn_mutex_lock_already = FALSE;
+ tmp_conn->mta_conn_mutex_unlock_later = FALSE;
+ SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos);
+ pthread_mutex_unlock(&tmp_conn->mta_conn_mutex);
my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0),
tmp_spider->share->server_names[0]);
error_num = ER_CONNECT_TO_FOREIGN_DATA_SOURCE;
@@ -10865,8 +11060,21 @@ int spider_db_udf_copy_tables(
(error_num = spider_db_set_names(tmp_spider, tmp_conn, 0)) ||
(error_num = spider_db_start_transaction(tmp_conn,
tmp_spider->need_mons))
- )
+ ) {
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already);
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later);
+ tmp_conn->mta_conn_mutex_lock_already = FALSE;
+ tmp_conn->mta_conn_mutex_unlock_later = FALSE;
+ SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos);
+ pthread_mutex_unlock(&tmp_conn->mta_conn_mutex);
goto error_start_transaction;
+ }
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already);
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later);
+ tmp_conn->mta_conn_mutex_lock_already = FALSE;
+ tmp_conn->mta_conn_mutex_unlock_later = FALSE;
+ SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos);
+ pthread_mutex_unlock(&tmp_conn->mta_conn_mutex);
}
}
} else {
@@ -10886,8 +11094,22 @@ int spider_db_udf_copy_tables(
{
tmp_spider = &spider[roop_count];
tmp_conn = tmp_spider->conns[0];
+ pthread_mutex_assert_not_owner(&tmp_conn->mta_conn_mutex);
+ pthread_mutex_lock(&tmp_conn->mta_conn_mutex);
+ SPIDER_SET_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos);
+ tmp_conn->need_mon = &tmp_spider->need_mons[0];
+ DBUG_ASSERT(!tmp_conn->mta_conn_mutex_lock_already);
+ DBUG_ASSERT(!tmp_conn->mta_conn_mutex_unlock_later);
+ tmp_conn->mta_conn_mutex_lock_already = TRUE;
+ tmp_conn->mta_conn_mutex_unlock_later = TRUE;
if (spider_db_ping(tmp_spider, tmp_conn, 0))
{
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already);
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later);
+ tmp_conn->mta_conn_mutex_lock_already = FALSE;
+ tmp_conn->mta_conn_mutex_unlock_later = FALSE;
+ SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos);
+ pthread_mutex_unlock(&tmp_conn->mta_conn_mutex);
my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0),
tmp_spider->share->server_names[0]);
error_num = ER_CONNECT_TO_FOREIGN_DATA_SOURCE;
@@ -10900,11 +11122,23 @@ int spider_db_udf_copy_tables(
(error_num = spider_db_lock_tables(tmp_spider, 0))
)
) {
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already);
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later);
+ tmp_conn->mta_conn_mutex_lock_already = FALSE;
+ tmp_conn->mta_conn_mutex_unlock_later = FALSE;
+ SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos);
+ pthread_mutex_unlock(&tmp_conn->mta_conn_mutex);
tmp_conn->table_lock = 0;
if (error_num == HA_ERR_OUT_OF_MEM)
my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
goto error_lock_tables;
}
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already);
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later);
+ tmp_conn->mta_conn_mutex_lock_already = FALSE;
+ tmp_conn->mta_conn_mutex_unlock_later = FALSE;
+ SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos);
+ pthread_mutex_unlock(&tmp_conn->mta_conn_mutex);
tmp_conn->table_lock = 1;
}
}
@@ -10912,11 +11146,23 @@ int spider_db_udf_copy_tables(
tmp_conn = src_tbl_conn->conn;
spider_conn_set_timeout_from_share(tmp_conn, 0,
copy_tables->trx->thd, src_tbl_conn->share);
+ pthread_mutex_assert_not_owner(&tmp_conn->mta_conn_mutex);
+ pthread_mutex_lock(&tmp_conn->mta_conn_mutex);
+ SPIDER_SET_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos);
+ tmp_conn->need_mon = &src_tbl_conn->need_mon;
+ DBUG_ASSERT(!tmp_conn->mta_conn_mutex_lock_already);
+ DBUG_ASSERT(!tmp_conn->mta_conn_mutex_unlock_later);
+ tmp_conn->mta_conn_mutex_lock_already = TRUE;
+ tmp_conn->mta_conn_mutex_unlock_later = TRUE;
if (select_ct->exec_query(
tmp_conn,
-1,
&src_tbl_conn->need_mon)
) {
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already);
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later);
+ tmp_conn->mta_conn_mutex_lock_already = FALSE;
+ tmp_conn->mta_conn_mutex_unlock_later = FALSE;
error_num = spider_db_errorno(tmp_conn);
if (error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM)
my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM,
@@ -10945,6 +11191,10 @@ int spider_db_udf_copy_tables(
my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
result->free_result();
delete result;
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already);
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later);
+ tmp_conn->mta_conn_mutex_lock_already = FALSE;
+ tmp_conn->mta_conn_mutex_unlock_later = FALSE;
SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&tmp_conn->mta_conn_mutex);
goto error_db_query;
@@ -10960,6 +11210,10 @@ int spider_db_udf_copy_tables(
my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
result->free_result();
delete result;
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already);
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later);
+ tmp_conn->mta_conn_mutex_lock_already = FALSE;
+ tmp_conn->mta_conn_mutex_unlock_later = FALSE;
SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&tmp_conn->mta_conn_mutex);
goto error_db_query;
@@ -10986,6 +11240,10 @@ int spider_db_udf_copy_tables(
my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
result->free_result();
delete result;
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already);
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later);
+ tmp_conn->mta_conn_mutex_lock_already = FALSE;
+ tmp_conn->mta_conn_mutex_unlock_later = FALSE;
SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&tmp_conn->mta_conn_mutex);
goto error_db_query;
@@ -11003,6 +11261,10 @@ int spider_db_udf_copy_tables(
my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
result->free_result();
delete result;
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already);
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later);
+ tmp_conn->mta_conn_mutex_lock_already = FALSE;
+ tmp_conn->mta_conn_mutex_unlock_later = FALSE;
SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&tmp_conn->mta_conn_mutex);
error_num = ER_OUT_OF_RESOURCES;
@@ -11015,12 +11277,20 @@ int spider_db_udf_copy_tables(
my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
result->free_result();
delete result;
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already);
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later);
+ tmp_conn->mta_conn_mutex_lock_already = FALSE;
+ tmp_conn->mta_conn_mutex_unlock_later = FALSE;
SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&tmp_conn->mta_conn_mutex);
goto error_db_query;
}
result->free_result();
delete result;
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already);
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later);
+ tmp_conn->mta_conn_mutex_lock_already = FALSE;
+ tmp_conn->mta_conn_mutex_unlock_later = FALSE;
SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&tmp_conn->mta_conn_mutex);
for (dst_tbl_conn = copy_tables->table_conn[1]; dst_tbl_conn;
@@ -11041,6 +11311,12 @@ int spider_db_udf_copy_tables(
}
if (error_num)
{
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already);
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later);
+ tmp_conn->mta_conn_mutex_lock_already = FALSE;
+ tmp_conn->mta_conn_mutex_unlock_later = FALSE;
+ SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos);
+ pthread_mutex_unlock(&tmp_conn->mta_conn_mutex);
if (error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM)
my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM,
ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0));
@@ -11048,6 +11324,10 @@ int spider_db_udf_copy_tables(
}
error_num = HA_ERR_END_OF_FILE;
end_of_file = TRUE;
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already);
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later);
+ tmp_conn->mta_conn_mutex_lock_already = FALSE;
+ tmp_conn->mta_conn_mutex_unlock_later = FALSE;
SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&tmp_conn->mta_conn_mutex);
}
@@ -11090,9 +11370,12 @@ int spider_db_udf_copy_tables(
{
tmp_conn = dst_tbl_conn->conn;
insert_ct = dst_tbl_conn->copy_table;
+ pthread_mutex_assert_not_owner(&tmp_conn->mta_conn_mutex);
pthread_mutex_lock(&tmp_conn->mta_conn_mutex);
SPIDER_SET_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos);
tmp_conn->need_mon = &dst_tbl_conn->need_mon;
+ DBUG_ASSERT(!tmp_conn->mta_conn_mutex_lock_already);
+ DBUG_ASSERT(!tmp_conn->mta_conn_mutex_unlock_later);
tmp_conn->mta_conn_mutex_lock_already = TRUE;
tmp_conn->mta_conn_mutex_unlock_later = TRUE;
spider_conn_set_timeout_from_share(tmp_conn, 0,
@@ -11102,6 +11385,8 @@ int spider_db_udf_copy_tables(
-1,
&dst_tbl_conn->need_mon)
) {
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already);
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later);
tmp_conn->mta_conn_mutex_lock_already = FALSE;
tmp_conn->mta_conn_mutex_unlock_later = FALSE;
error_num = spider_db_errorno(tmp_conn);
@@ -11110,6 +11395,8 @@ int spider_db_udf_copy_tables(
ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0));
goto error_db_query;
} else {
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already);
+ DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later);
tmp_conn->mta_conn_mutex_lock_already = FALSE;
tmp_conn->mta_conn_mutex_unlock_later = FALSE;
SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos);
@@ -11250,8 +11537,6 @@ int spider_db_open_handler(
int link_idx
) {
int error_num;
- bool tmp_mta_conn_mutex_lock_already;
- bool tmp_mta_conn_mutex_unlock_later;
SPIDER_SHARE *share = spider->share;
uint *handler_id_ptr =
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
@@ -11266,16 +11551,14 @@ int spider_db_open_handler(
;
spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id];
DBUG_ENTER("spider_db_open_handler");
- if (!conn->mta_conn_mutex_lock_already)
- {
- pthread_mutex_lock(&conn->mta_conn_mutex);
- SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
- conn->need_mon = &spider->need_mons[link_idx];
- }
+ 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[link_idx];
DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name);
- tmp_mta_conn_mutex_lock_already = conn->mta_conn_mutex_lock_already;
+ DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
+ DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later);
conn->mta_conn_mutex_lock_already = TRUE;
- tmp_mta_conn_mutex_unlock_later = conn->mta_conn_mutex_unlock_later;
conn->mta_conn_mutex_unlock_later = TRUE;
if (!spider->handler_opened(link_idx, conn->conn_kind))
*handler_id_ptr = conn->opened_handlers;
@@ -11324,11 +11607,6 @@ int spider_db_open_handler(
{
my_printf_error(ER_SPIDER_HS_NUM, ER_SPIDER_HS_STR, MYF(0),
conn->db_conn->get_errno(), conn->db_conn->get_error());
- if (!conn->mta_conn_mutex_unlock_later)
- {
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- }
spider->need_mons[link_idx] = ER_SPIDER_HS_NUM;
error_num = ER_SPIDER_HS_NUM;
goto error;
@@ -11464,23 +11742,21 @@ int spider_db_open_handler(
}
DBUG_PRINT("info",("spider conn=%p", conn));
DBUG_PRINT("info",("spider opened_handlers=%u", conn->opened_handlers));
- conn->mta_conn_mutex_lock_already = tmp_mta_conn_mutex_lock_already;
- conn->mta_conn_mutex_unlock_later = tmp_mta_conn_mutex_unlock_later;
- if (!tmp_mta_conn_mutex_unlock_later)
- {
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- }
+ 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);
DBUG_RETURN(0);
error:
- conn->mta_conn_mutex_lock_already = tmp_mta_conn_mutex_lock_already;
- conn->mta_conn_mutex_unlock_later = tmp_mta_conn_mutex_unlock_later;
- if (!tmp_mta_conn_mutex_unlock_later)
- {
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- }
+ 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);
DBUG_RETURN(error_num);
}
@@ -11530,6 +11806,7 @@ int spider_db_bulk_open_handler(
}
bool tmp_mta_conn_mutex_unlock_later;
+ pthread_mutex_assert_owner(&conn->mta_conn_mutex);
tmp_mta_conn_mutex_unlock_later = conn->mta_conn_mutex_unlock_later;
conn->mta_conn_mutex_unlock_later = TRUE;
SPIDER_DB_RESULT *result;
@@ -11568,24 +11845,19 @@ int spider_db_close_handler(
uint tgt_conn_kind
) {
int error_num;
- bool tmp_mta_conn_mutex_lock_already;
- bool tmp_mta_conn_mutex_unlock_later;
spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id];
DBUG_ENTER("spider_db_close_handler");
DBUG_PRINT("info",("spider conn=%p", 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 = &spider->need_mons[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;
if (spider->handler_opened(link_idx, tgt_conn_kind))
{
- if (!conn->mta_conn_mutex_lock_already)
- {
- pthread_mutex_lock(&conn->mta_conn_mutex);
- SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
- conn->need_mon = &spider->need_mons[link_idx];
- }
- DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name);
- tmp_mta_conn_mutex_lock_already = conn->mta_conn_mutex_lock_already;
- conn->mta_conn_mutex_lock_already = TRUE;
- tmp_mta_conn_mutex_unlock_later = conn->mta_conn_mutex_unlock_later;
- conn->mta_conn_mutex_unlock_later = TRUE;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL)
{
@@ -11593,7 +11865,15 @@ int spider_db_close_handler(
dbton_hdl->reset_sql(SPIDER_SQL_TYPE_HANDLER);
if ((error_num = dbton_hdl->append_close_handler_part(
SPIDER_SQL_TYPE_HANDLER, 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);
DBUG_RETURN(error_num);
+ }
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
spider->share);
@@ -11619,24 +11899,22 @@ int spider_db_close_handler(
goto error;
conn->opened_handlers--;
DBUG_PRINT("info",("spider opened_handlers=%u", conn->opened_handlers));
- conn->mta_conn_mutex_lock_already = tmp_mta_conn_mutex_lock_already;
- conn->mta_conn_mutex_unlock_later = tmp_mta_conn_mutex_unlock_later;
- if (!tmp_mta_conn_mutex_unlock_later)
- {
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- }
}
+ 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);
DBUG_RETURN(0);
error:
- conn->mta_conn_mutex_lock_already = tmp_mta_conn_mutex_lock_already;
- conn->mta_conn_mutex_unlock_later = tmp_mta_conn_mutex_unlock_later;
- if (!tmp_mta_conn_mutex_unlock_later)
- {
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- }
+ 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);
DBUG_RETURN(error_num);
}
@@ -11673,3 +11951,4 @@ bool spider_db_conn_is_network_error(
}
DBUG_RETURN(FALSE);
}
+
diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc
index 6ee4be4c7cc..128cd494e7f 100644
--- a/storage/spider/spd_db_mysql.cc
+++ b/storage/spider/spd_db_mysql.cc
@@ -2185,10 +2185,6 @@ void spider_db_mbase::print_warnings(
if (!(db_conn->server_status & SERVER_MORE_RESULTS_EXISTS))
#endif
{
-/*
- pthread_mutex_lock(&conn->mta_conn_mutex);
- SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
-*/
if (
spider_param_dry_access() ||
!mysql_real_query(db_conn, SPIDER_SQL_SHOW_WARNINGS_STR,
@@ -2206,18 +2202,10 @@ void spider_db_mbase::print_warnings(
{
if (res)
mysql_free_result(res);
-/*
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
-*/
DBUG_VOID_RETURN;
}
/* no record is ok */
}
-/*
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
-*/
num_fields = mysql_num_fields(res);
if (num_fields != 3)
{
@@ -2236,11 +2224,6 @@ void spider_db_mbase::print_warnings(
}
if (res)
mysql_free_result(res);
- } else {
-/*
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
-*/
}
}
}
@@ -2380,14 +2363,31 @@ int spider_db_mbase::consistent_snapshot(
) {
DBUG_ENTER("spider_db_mbase::consistent_snapshot");
DBUG_PRINT("info",("spider this=%p", this));
+ 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;
if (spider_db_query(
conn,
SPIDER_SQL_START_CONSISTENT_SNAPSHOT_STR,
SPIDER_SQL_START_CONSISTENT_SNAPSHOT_LEN,
-1,
need_mon)
- )
+ ) {
+ 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;
DBUG_RETURN(spider_db_errorno(conn));
+ }
+ 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);
DBUG_RETURN(0);
@@ -2405,16 +2405,18 @@ int spider_db_mbase::start_transaction(
) {
DBUG_ENTER("spider_db_mbase::start_transaction");
DBUG_PRINT("info",("spider this=%p", this));
+ pthread_mutex_assert_owner(&conn->mta_conn_mutex);
+ DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
+ DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
if (spider_db_query(
conn,
SPIDER_SQL_START_TRANSACTION_STR,
SPIDER_SQL_START_TRANSACTION_LEN,
-1,
need_mon)
- )
+ ) {
DBUG_RETURN(spider_db_errorno(conn));
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
+ }
DBUG_RETURN(0);
}
@@ -2423,14 +2425,31 @@ int spider_db_mbase::commit(
) {
DBUG_ENTER("spider_db_mbase::commit");
DBUG_PRINT("info",("spider this=%p", this));
+ 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;
if (spider_db_query(
conn,
SPIDER_SQL_COMMIT_STR,
SPIDER_SQL_COMMIT_LEN,
-1,
need_mon)
- )
+ ) {
+ 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;
DBUG_RETURN(spider_db_errorno(conn));
+ }
+ 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);
DBUG_RETURN(0);
@@ -2443,6 +2462,13 @@ int spider_db_mbase::rollback(
int error_num;
DBUG_ENTER("spider_db_mbase::rollback");
DBUG_PRINT("info",("spider this=%p", this));
+ 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;
if (spider_db_query(
conn,
@@ -2459,12 +2485,18 @@ int spider_db_mbase::rollback(
)
conn->thd->clear_error();
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);
pthread_mutex_unlock(&conn->mta_conn_mutex);
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);
pthread_mutex_unlock(&conn->mta_conn_mutex);
@@ -2501,14 +2533,31 @@ int spider_db_mbase::xa_end(
sql_str.length(0);
sql_str.q_append(SPIDER_SQL_XA_END_STR, SPIDER_SQL_XA_END_LEN);
spider_db_append_xid_str(&sql_str, xid);
+ 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;
if (spider_db_query(
conn,
sql_str.ptr(),
sql_str.length(),
-1,
need_mon)
- )
+ ) {
+ 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;
DBUG_RETURN(spider_db_errorno(conn));
+ }
+ 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);
DBUG_RETURN(0);
@@ -2527,14 +2576,31 @@ int spider_db_mbase::xa_prepare(
sql_str.length(0);
sql_str.q_append(SPIDER_SQL_XA_PREPARE_STR, SPIDER_SQL_XA_PREPARE_LEN);
spider_db_append_xid_str(&sql_str, xid);
+ 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;
if (spider_db_query(
conn,
sql_str.ptr(),
sql_str.length(),
-1,
need_mon)
- )
+ ) {
+ 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;
DBUG_RETURN(spider_db_errorno(conn));
+ }
+ 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);
DBUG_RETURN(0);
@@ -2553,14 +2619,31 @@ int spider_db_mbase::xa_commit(
sql_str.length(0);
sql_str.q_append(SPIDER_SQL_XA_COMMIT_STR, SPIDER_SQL_XA_COMMIT_LEN);
spider_db_append_xid_str(&sql_str, xid);
+ 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;
if (spider_db_query(
conn,
sql_str.ptr(),
sql_str.length(),
-1,
need_mon)
- )
+ ) {
+ 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;
DBUG_RETURN(spider_db_errorno(conn));
+ }
+ 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);
DBUG_RETURN(0);
@@ -2579,14 +2662,31 @@ int spider_db_mbase::xa_rollback(
sql_str.length(0);
sql_str.q_append(SPIDER_SQL_XA_ROLLBACK_STR, SPIDER_SQL_XA_ROLLBACK_LEN);
spider_db_append_xid_str(&sql_str, xid);
+ 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;
if (spider_db_query(
conn,
sql_str.ptr(),
sql_str.length(),
-1,
need_mon)
- )
+ ) {
+ 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;
DBUG_RETURN(spider_db_errorno(conn));
+ }
+ 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);
DBUG_RETURN(0);
@@ -2608,50 +2708,118 @@ int spider_db_mbase::set_trx_isolation(
switch (trx_isolation)
{
case ISO_READ_UNCOMMITTED:
+ 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;
if (spider_db_query(
conn,
SPIDER_SQL_ISO_READ_UNCOMMITTED_STR,
SPIDER_SQL_ISO_READ_UNCOMMITTED_LEN,
-1,
need_mon)
- )
+ ) {
+ 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;
DBUG_RETURN(spider_db_errorno(conn));
+ }
+ 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);
break;
case ISO_READ_COMMITTED:
+ 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;
if (spider_db_query(
conn,
SPIDER_SQL_ISO_READ_COMMITTED_STR,
SPIDER_SQL_ISO_READ_COMMITTED_LEN,
-1,
need_mon)
- )
+ ) {
+ 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;
DBUG_RETURN(spider_db_errorno(conn));
+ }
+ 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);
break;
case ISO_REPEATABLE_READ:
+ 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;
if (spider_db_query(
conn,
SPIDER_SQL_ISO_REPEATABLE_READ_STR,
SPIDER_SQL_ISO_REPEATABLE_READ_LEN,
-1,
need_mon)
- )
+ ) {
+ 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;
DBUG_RETURN(spider_db_errorno(conn));
+ }
+ 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);
break;
case ISO_SERIALIZABLE:
+ 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;
if (spider_db_query(
conn,
SPIDER_SQL_ISO_SERIALIZABLE_STR,
SPIDER_SQL_ISO_SERIALIZABLE_LEN,
-1,
need_mon)
- )
+ ) {
+ 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;
DBUG_RETURN(spider_db_errorno(conn));
+ }
+ 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);
break;
@@ -2676,25 +2844,59 @@ int spider_db_mbase::set_autocommit(
DBUG_PRINT("info",("spider this=%p", this));
if (autocommit)
{
+ 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;
if (spider_db_query(
conn,
SPIDER_SQL_AUTOCOMMIT_ON_STR,
SPIDER_SQL_AUTOCOMMIT_ON_LEN,
-1,
need_mon)
- )
+ ) {
+ 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;
DBUG_RETURN(spider_db_errorno(conn));
+ }
+ 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);
} else {
+ 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;
if (spider_db_query(
conn,
SPIDER_SQL_AUTOCOMMIT_OFF_STR,
SPIDER_SQL_AUTOCOMMIT_OFF_LEN,
-1,
need_mon)
- )
+ ) {
+ 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;
DBUG_RETURN(spider_db_errorno(conn));
+ }
+ 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);
}
@@ -2716,25 +2918,59 @@ int spider_db_mbase::set_sql_log_off(
DBUG_PRINT("info",("spider this=%p", this));
if (sql_log_off)
{
+ 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;
if (spider_db_query(
conn,
SPIDER_SQL_SQL_LOG_ON_STR,
SPIDER_SQL_SQL_LOG_ON_LEN,
-1,
need_mon)
- )
+ ) {
+ 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;
DBUG_RETURN(spider_db_errorno(conn));
+ }
+ 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);
} else {
+ 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;
if (spider_db_query(
conn,
SPIDER_SQL_SQL_LOG_OFF_STR,
SPIDER_SQL_SQL_LOG_OFF_LEN,
-1,
need_mon)
- )
+ ) {
+ 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;
DBUG_RETURN(spider_db_errorno(conn));
+ }
+ 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);
}
@@ -2765,14 +3001,31 @@ int spider_db_mbase::set_time_zone(
sql_str.q_append(SPIDER_SQL_TIME_ZONE_STR, SPIDER_SQL_TIME_ZONE_LEN);
sql_str.q_append(tz_str->ptr(), tz_str->length());
sql_str.q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN);
+ 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;
if (spider_db_query(
conn,
sql_str.ptr(),
sql_str.length(),
-1,
need_mon)
- )
+ ) {
+ 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;
DBUG_RETURN(spider_db_errorno(conn));
+ }
+ 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);
DBUG_RETURN(0);
@@ -2789,9 +3042,12 @@ int spider_db_mbase::exec_simple_sql_with_result(
) {
int error_num;
DBUG_ENTER("spider_db_mbase::exec_simple_sql_with_result");
+ 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;
spider_conn_set_timeout_from_share(conn, all_link_idx, trx->thd,
@@ -2817,6 +3073,8 @@ int spider_db_mbase::exec_simple_sql_with_result(
if ((error_num = spider_db_ping_internal(share, conn,
all_link_idx, need_mon)))
{
+ 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);
@@ -2827,6 +3085,8 @@ int spider_db_mbase::exec_simple_sql_with_result(
if ((error_num = spider_db_set_names_internal(trx, share, conn,
all_link_idx, need_mon)))
{
+ 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);
@@ -2843,12 +3103,16 @@ int spider_db_mbase::exec_simple_sql_with_result(
-1,
need_mon)
) {
+ 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;
DBUG_PRINT("info", ("spider error_num=%d 3", error_num));
DBUG_RETURN(spider_db_errorno(conn));
}
} 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);
@@ -2859,18 +3123,29 @@ int spider_db_mbase::exec_simple_sql_with_result(
}
if (!(*res = store_result(NULL, NULL, &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;
- if (error_num || (error_num = spider_db_errorno(conn)))
+ if (error_num)
{
+ SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
+ pthread_mutex_unlock(&conn->mta_conn_mutex);
DBUG_PRINT("info", ("spider error_num=%d 5", error_num));
DBUG_RETURN(error_num);
+ }
+ else if ((error_num = spider_db_errorno(conn)))
+ {
+ DBUG_PRINT("info", ("spider error_num=%d 6", error_num));
+ DBUG_RETURN(error_num);
} else {
- DBUG_PRINT("info", ("spider error_num=%d 6",
+ DBUG_PRINT("info", ("spider error_num=%d 7",
ER_QUERY_ON_FOREIGN_DATA_SOURCE));
DBUG_RETURN(ER_QUERY_ON_FOREIGN_DATA_SOURCE);
}
}
+ 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);
@@ -6507,6 +6782,14 @@ int spider_mbase_share::discover_table_structure(
) {
DBUG_RETURN(error_num);
}
+ 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;
if (!conn->disable_reconnect)
{
ha_spider tmp_spider;
@@ -6519,14 +6802,15 @@ int spider_mbase_share::discover_table_structure(
if ((error_num = spider_db_ping(&tmp_spider, conn, 0)))
{
DBUG_PRINT("info",("spider spider_db_ping error"));
+ 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);
continue;
}
}
- pthread_mutex_lock(&conn->mta_conn_mutex);
- SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
- conn->need_mon = &need_mon;
- conn->mta_conn_mutex_lock_already = TRUE;
- conn->mta_conn_mutex_unlock_later = TRUE;
spider_conn_set_timeout_from_share(conn, roop_count, trx->thd,
spider_share);
if (
@@ -6543,6 +6827,8 @@ int spider_mbase_share::discover_table_structure(
)
) {
DBUG_PRINT("info",("spider spider_get_trx error"));
+ 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);
@@ -6562,6 +6848,8 @@ int spider_mbase_share::discover_table_structure(
if (error_num || (error_num = spider_db_errorno(conn)))
{
DBUG_PRINT("info",("spider column store error"));
+ 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);
@@ -6570,6 +6858,8 @@ int spider_mbase_share::discover_table_structure(
}
/* no record */
DBUG_PRINT("info",("spider column no record error"));
+ 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);
@@ -6582,6 +6872,8 @@ int spider_mbase_share::discover_table_structure(
DBUG_PRINT("info",("spider column fetch error"));
res->free_result();
delete res;
+ 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);
@@ -6598,6 +6890,8 @@ int spider_mbase_share::discover_table_structure(
if (conn->db_conn->next_result())
{
DBUG_PRINT("info",("spider single result error"));
+ 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);
@@ -6610,6 +6904,8 @@ int spider_mbase_share::discover_table_structure(
if (error_num || (error_num = spider_db_errorno(conn)))
{
DBUG_PRINT("info",("spider index store error"));
+ 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);
@@ -6618,6 +6914,8 @@ int spider_mbase_share::discover_table_structure(
}
/* no record */
DBUG_PRINT("info",("spider index no record error"));
+ 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);
@@ -6630,6 +6928,8 @@ int spider_mbase_share::discover_table_structure(
DBUG_PRINT("info",("spider index fetch error"));
res->free_result();
delete res;
+ 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);
@@ -6641,6 +6941,8 @@ int spider_mbase_share::discover_table_structure(
if (conn->db_conn->next_result())
{
DBUG_PRINT("info",("spider dual result error"));
+ 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);
@@ -6653,6 +6955,8 @@ int spider_mbase_share::discover_table_structure(
if (error_num || (error_num = spider_db_errorno(conn)))
{
DBUG_PRINT("info",("spider table store error"));
+ 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);
@@ -6661,6 +6965,8 @@ int spider_mbase_share::discover_table_structure(
}
/* no record */
DBUG_PRINT("info",("spider table no record error"));
+ 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);
@@ -6673,6 +6979,8 @@ int spider_mbase_share::discover_table_structure(
DBUG_PRINT("info",("spider table fetch error"));
res->free_result();
delete res;
+ 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);
@@ -6681,6 +6989,8 @@ int spider_mbase_share::discover_table_structure(
}
res->free_result();
delete res;
+ 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);
@@ -12076,9 +12386,12 @@ int spider_mbase_handler::show_table_status(
if (sts_mode == 1)
{
+ 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[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->disable_connect_retry = TRUE;
@@ -12104,6 +12417,8 @@ int spider_mbase_handler::show_table_status(
if ((error_num = spider_db_ping(spider, conn, link_idx)))
{
conn->disable_connect_retry = FALSE;
+ 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);
@@ -12113,6 +12428,8 @@ int spider_mbase_handler::show_table_status(
if ((error_num = spider_db_set_names(spider, conn, link_idx)))
{
conn->disable_connect_retry = FALSE;
+ 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);
@@ -12129,12 +12446,16 @@ int spider_mbase_handler::show_table_status(
&spider->need_mons[link_idx])
) {
conn->disable_connect_retry = FALSE;
+ 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;
DBUG_RETURN(spider_db_errorno(conn));
}
} else {
conn->disable_connect_retry = FALSE;
+ 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);
@@ -12151,6 +12472,8 @@ int spider_mbase_handler::show_table_status(
if (spider_param_dry_access())
{
conn->disable_connect_retry = FALSE;
+ 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);
@@ -12160,9 +12483,17 @@ int spider_mbase_handler::show_table_status(
if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num)))
{
conn->disable_connect_retry = FALSE;
+ 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 (error_num || (error_num = spider_db_errorno(conn)))
+ if (error_num)
+ {
+ SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
+ pthread_mutex_unlock(&conn->mta_conn_mutex);
+ DBUG_RETURN(error_num);
+ }
+ else if ((error_num = spider_db_errorno(conn)))
DBUG_RETURN(error_num);
else {
my_printf_error(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM,
@@ -12174,6 +12505,8 @@ int spider_mbase_handler::show_table_status(
}
}
conn->disable_connect_retry = FALSE;
+ 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);
@@ -12216,9 +12549,12 @@ int spider_mbase_handler::show_table_status(
DBUG_RETURN(error_num);
}
} else {
+ 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[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->disable_connect_retry = TRUE;
@@ -12244,6 +12580,8 @@ int spider_mbase_handler::show_table_status(
if ((error_num = spider_db_ping(spider, conn, link_idx)))
{
conn->disable_connect_retry = FALSE;
+ 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);
@@ -12253,6 +12591,8 @@ int spider_mbase_handler::show_table_status(
if ((error_num = spider_db_set_names(spider, conn, link_idx)))
{
conn->disable_connect_retry = FALSE;
+ 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);
@@ -12269,12 +12609,16 @@ int spider_mbase_handler::show_table_status(
&spider->need_mons[link_idx])
) {
conn->disable_connect_retry = FALSE;
+ 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;
DBUG_RETURN(spider_db_errorno(conn));
}
} else {
conn->disable_connect_retry = FALSE;
+ 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);
@@ -12291,6 +12635,8 @@ int spider_mbase_handler::show_table_status(
if (spider_param_dry_access())
{
conn->disable_connect_retry = FALSE;
+ 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);
@@ -12300,6 +12646,8 @@ int spider_mbase_handler::show_table_status(
if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num)))
{
conn->disable_connect_retry = FALSE;
+ 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 (error_num || (error_num = spider_db_errorno(conn)))
@@ -12308,6 +12656,8 @@ int spider_mbase_handler::show_table_status(
DBUG_RETURN(ER_QUERY_ON_FOREIGN_DATA_SOURCE);
}
conn->disable_connect_retry = FALSE;
+ 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);
@@ -12391,9 +12741,12 @@ int spider_mbase_handler::show_index(
DBUG_PRINT("info",("spider crd_mode=%d", crd_mode));
if (crd_mode == 1)
{
+ 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[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;
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
@@ -12417,6 +12770,8 @@ int spider_mbase_handler::show_index(
/* retry */
if ((error_num = spider_db_ping(spider, 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);
@@ -12425,6 +12780,8 @@ int spider_mbase_handler::show_index(
}
if ((error_num = spider_db_set_names(spider, 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);
@@ -12440,11 +12797,15 @@ int spider_mbase_handler::show_index(
-1,
&spider->need_mons[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;
DBUG_RETURN(spider_db_errorno(conn));
}
} 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);
@@ -12462,6 +12823,8 @@ int spider_mbase_handler::show_index(
{
if (error_num || (error_num = spider_db_errorno(conn)))
{
+ 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);
@@ -12470,6 +12833,8 @@ int spider_mbase_handler::show_index(
}
/* no record is ok */
}
+ 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);
@@ -12524,9 +12889,12 @@ int spider_mbase_handler::show_index(
DBUG_RETURN(error_num);
}
} else {
+ 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[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;
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
@@ -12550,6 +12918,8 @@ int spider_mbase_handler::show_index(
/* retry */
if ((error_num = spider_db_ping(spider, 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);
@@ -12558,6 +12928,8 @@ int spider_mbase_handler::show_index(
}
if ((error_num = spider_db_set_names(spider, 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);
@@ -12573,11 +12945,15 @@ int spider_mbase_handler::show_index(
-1,
&spider->need_mons[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;
DBUG_RETURN(spider_db_errorno(conn));
}
} 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);
@@ -12595,6 +12971,8 @@ int spider_mbase_handler::show_index(
{
if (error_num || (error_num = spider_db_errorno(conn)))
{
+ 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);
@@ -12603,6 +12981,8 @@ int spider_mbase_handler::show_index(
}
/* no record is ok */
}
+ 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);
@@ -12669,9 +13049,12 @@ int spider_mbase_handler::show_records(
SPIDER_SHARE *share = spider->share;
uint pos = spider->conn_link_idx[link_idx];
DBUG_ENTER("spider_mbase_handler::show_records");
+ 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[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;
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
@@ -12695,6 +13078,8 @@ int spider_mbase_handler::show_records(
/* retry */
if ((error_num = spider_db_ping(spider, 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);
@@ -12704,6 +13089,8 @@ int spider_mbase_handler::show_records(
}
if ((error_num = spider_db_set_names(spider, 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);
@@ -12720,12 +13107,16 @@ int spider_mbase_handler::show_records(
-1,
&spider->need_mons[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;
DBUG_PRINT("info", ("spider error_num=%d 3", error_num));
DBUG_RETURN(spider_db_errorno(conn));
}
} 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);
@@ -12742,18 +13133,29 @@ int spider_mbase_handler::show_records(
request_key.next = NULL;
if (!(res = conn->db_conn->store_result(NULL, &request_key, &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;
- if (error_num || (error_num = spider_db_errorno(conn)))
+ if (error_num)
{
+ SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
+ pthread_mutex_unlock(&conn->mta_conn_mutex);
DBUG_PRINT("info", ("spider error_num=%d 5", error_num));
DBUG_RETURN(error_num);
+ }
+ else if ((error_num = spider_db_errorno(conn)))
+ {
+ DBUG_PRINT("info", ("spider error_num=%d 6", error_num));
+ DBUG_RETURN(error_num);
} else {
- DBUG_PRINT("info", ("spider error_num=%d 6",
+ DBUG_PRINT("info", ("spider error_num=%d 7",
ER_QUERY_ON_FOREIGN_DATA_SOURCE));
DBUG_RETURN(ER_QUERY_ON_FOREIGN_DATA_SOURCE);
}
}
+ 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);
@@ -12803,9 +13205,12 @@ ha_rows spider_mbase_handler::explain_select(
DBUG_RETURN(HA_POS_ERROR);
}
+ 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[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;
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
@@ -12831,6 +13236,8 @@ ha_rows spider_mbase_handler::explain_select(
{
if (spider->check_error_mode(error_num))
my_errno = 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);
@@ -12841,6 +13248,8 @@ ha_rows spider_mbase_handler::explain_select(
{
if (spider->check_error_mode(error_num))
my_errno = 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);
@@ -12859,6 +13268,8 @@ ha_rows spider_mbase_handler::explain_select(
error_num = spider_db_errorno(conn);
if (spider->check_error_mode(error_num))
my_errno = 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);
@@ -12868,6 +13279,8 @@ ha_rows spider_mbase_handler::explain_select(
} else {
if (spider->check_error_mode(error_num))
my_errno = 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);
@@ -12887,6 +13300,8 @@ ha_rows spider_mbase_handler::explain_select(
{
if (spider->check_error_mode(error_num))
my_errno = 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);
@@ -12894,6 +13309,8 @@ ha_rows spider_mbase_handler::explain_select(
DBUG_RETURN(HA_POS_ERROR);
} else {
my_errno = ER_QUERY_ON_FOREIGN_DATA_SOURCE;
+ 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);
@@ -12901,6 +13318,8 @@ ha_rows spider_mbase_handler::explain_select(
DBUG_RETURN(HA_POS_ERROR);
}
}
+ 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);
@@ -12933,13 +13352,18 @@ int spider_mbase_handler::lock_tables(
}
if (str->length())
{
+ 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[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;
if ((error_num = spider_db_set_names(spider, 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);
@@ -12955,10 +13379,14 @@ int spider_mbase_handler::lock_tables(
-1,
&spider->need_mons[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;
DBUG_RETURN(spider_db_errorno(conn));
}
+ 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);
@@ -12993,14 +13421,31 @@ int spider_mbase_handler::unlock_tables(
{
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
spider->share);
+ 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[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;
if (spider_db_query(
conn,
str->ptr(),
str->length(),
-1,
&spider->need_mons[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;
DBUG_RETURN(spider_db_errorno(conn));
+ }
+ 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);
}
@@ -13023,13 +13468,18 @@ int spider_mbase_handler::disable_keys(
{
DBUG_RETURN(error_num);
}
+ 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[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;
if ((error_num = spider_db_set_names(spider, 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);
@@ -13045,11 +13495,15 @@ int spider_mbase_handler::disable_keys(
-1,
&spider->need_mons[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;
error_num = spider_db_errorno(conn);
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);
@@ -13072,13 +13526,18 @@ int spider_mbase_handler::enable_keys(
{
DBUG_RETURN(error_num);
}
+ 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[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;
if ((error_num = spider_db_set_names(spider, 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);
@@ -13094,11 +13553,15 @@ int spider_mbase_handler::enable_keys(
-1,
&spider->need_mons[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;
error_num = spider_db_errorno(conn);
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);
@@ -13122,13 +13585,18 @@ int spider_mbase_handler::check_table(
{
DBUG_RETURN(error_num);
}
+ 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[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;
if ((error_num = spider_db_set_names(spider, 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);
@@ -13144,11 +13612,15 @@ int spider_mbase_handler::check_table(
-1,
&spider->need_mons[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;
error_num = spider_db_errorno(conn);
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);
@@ -13172,13 +13644,18 @@ int spider_mbase_handler::repair_table(
{
DBUG_RETURN(error_num);
}
+ 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[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;
if ((error_num = spider_db_set_names(spider, 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);
@@ -13194,11 +13671,15 @@ int spider_mbase_handler::repair_table(
-1,
&spider->need_mons[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;
error_num = spider_db_errorno(conn);
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);
@@ -13221,13 +13702,18 @@ int spider_mbase_handler::analyze_table(
{
DBUG_RETURN(error_num);
}
+ 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[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;
if ((error_num = spider_db_set_names(spider, 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);
@@ -13243,11 +13729,15 @@ int spider_mbase_handler::analyze_table(
-1,
&spider->need_mons[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;
error_num = spider_db_errorno(conn);
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);
@@ -13270,13 +13760,18 @@ int spider_mbase_handler::optimize_table(
{
DBUG_RETURN(error_num);
}
+ 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[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;
if ((error_num = spider_db_set_names(spider, 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);
@@ -13292,11 +13787,15 @@ int spider_mbase_handler::optimize_table(
-1,
&spider->need_mons[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;
error_num = spider_db_errorno(conn);
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);
@@ -13322,6 +13821,14 @@ int spider_mbase_handler::flush_tables(
}
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
share);
+ 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[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;
if (spider_db_query(
conn,
str->ptr(),
@@ -13329,9 +13836,17 @@ int spider_mbase_handler::flush_tables(
-1,
&spider->need_mons[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;
error_num = spider_db_errorno(conn);
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);
pthread_mutex_unlock(&conn->mta_conn_mutex);
DBUG_RETURN(0);
@@ -13347,6 +13862,14 @@ int spider_mbase_handler::flush_logs(
DBUG_PRINT("info",("spider this=%p", this));
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
share);
+ 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[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;
if (spider_db_query(
conn,
SPIDER_SQL_FLUSH_LOGS_STR,
@@ -13354,9 +13877,17 @@ int spider_mbase_handler::flush_logs(
-1,
&spider->need_mons[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;
error_num = spider_db_errorno(conn);
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);
pthread_mutex_unlock(&conn->mta_conn_mutex);
DBUG_RETURN(0);
diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc
index 08d7d3e083d..d3147c19f2f 100644
--- a/storage/spider/spd_db_oracle.cc
+++ b/storage/spider/spd_db_oracle.cc
@@ -1804,16 +1804,18 @@ int spider_db_oracle::start_transaction(
}
DBUG_RETURN(set_trx_isolation(conn->trx_isolation, need_mon));
}
+ pthread_mutex_assert_owner(&conn->mta_conn_mutex);
+ DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
+ DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
if (spider_db_query(
conn,
SPIDER_SQL_START_TRANSACTION_STR,
SPIDER_SQL_START_TRANSACTION_LEN,
-1,
need_mon)
- )
+ ) {
DBUG_RETURN(spider_db_errorno(conn));
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
+ }
DBUG_RETURN(0);
}
@@ -2002,14 +2004,31 @@ int spider_db_oracle::set_trx_isolation(
DBUG_RETURN(exec_query(SPIDER_SQL_ISO_READ_COMMITTED_STR,
SPIDER_SQL_ISO_READ_COMMITTED_LEN, -1));
}
+ 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;
if (spider_db_query(
conn,
SPIDER_SQL_ISO_READ_COMMITTED_STR,
SPIDER_SQL_ISO_READ_COMMITTED_LEN,
-1,
need_mon)
- )
+ ) {
+ 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;
DBUG_RETURN(spider_db_errorno(conn));
+ }
+ 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);
break;
@@ -2020,14 +2039,31 @@ int spider_db_oracle::set_trx_isolation(
DBUG_RETURN(exec_query(SPIDER_SQL_ISO_SERIALIZABLE_STR,
SPIDER_SQL_ISO_SERIALIZABLE_LEN, -1));
}
+ 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;
if (spider_db_query(
conn,
SPIDER_SQL_ISO_SERIALIZABLE_STR,
SPIDER_SQL_ISO_SERIALIZABLE_LEN,
-1,
need_mon)
- )
+ ) {
+ 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;
DBUG_RETURN(spider_db_errorno(conn));
+ }
+ 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);
break;
@@ -2057,14 +2093,31 @@ int spider_db_oracle::set_autocommit(
DBUG_RETURN(exec_query(SPIDER_SQL_AUTOCOMMIT_ON_STR,
SPIDER_SQL_AUTOCOMMIT_ON_LEN, -1));
}
+ 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;
if (spider_db_query(
conn,
SPIDER_SQL_AUTOCOMMIT_ON_STR,
SPIDER_SQL_AUTOCOMMIT_ON_LEN,
-1,
need_mon)
- )
+ ) {
+ 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;
DBUG_RETURN(spider_db_errorno(conn));
+ }
+ 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);
} else {
@@ -2073,14 +2126,31 @@ int spider_db_oracle::set_autocommit(
DBUG_RETURN(exec_query(SPIDER_SQL_AUTOCOMMIT_OFF_STR,
SPIDER_SQL_AUTOCOMMIT_OFF_LEN, -1));
}
+ 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;
if (spider_db_query(
conn,
SPIDER_SQL_AUTOCOMMIT_OFF_STR,
SPIDER_SQL_AUTOCOMMIT_OFF_LEN,
-1,
need_mon)
- )
+ ) {
+ 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;
DBUG_RETURN(spider_db_errorno(conn));
+ }
+ 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);
}
@@ -10990,112 +11060,6 @@ int spider_oracle_handler::show_table_status(
if (sts_mode == 1)
{
-/*
- pthread_mutex_lock(&conn->mta_conn_mutex);
- SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
- conn->need_mon = &spider->need_mons[link_idx];
- conn->mta_conn_mutex_lock_already = TRUE;
- conn->mta_conn_mutex_unlock_later = TRUE;
- spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
- share);
- if (
- (error_num = spider_db_set_names(spider, conn, link_idx)) ||
- (
- spider_db_query(
- conn,
- oracle_share->show_table_status[0 + pos].ptr(),
- oracle_share->show_table_status[0 + pos].length(),
- -1,
- &spider->need_mons[link_idx]) &&
- (error_num = spider_db_errorno(conn))
- )
- ) {
- if (
- error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM &&
- !conn->disable_reconnect
- ) {
-*/
- /* retry */
-/*
- if ((error_num = spider_db_ping(spider, conn, link_idx)))
- {
- 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);
- DBUG_RETURN(error_num);
- }
- if ((error_num = spider_db_set_names(spider, conn, link_idx)))
- {
- 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);
- DBUG_RETURN(error_num);
- }
- spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
- share);
- if (spider_db_query(
- conn,
- oracle_share->show_table_status[0 + pos].ptr(),
- oracle_share->show_table_status[0 + pos].length(),
- -1,
- &spider->need_mons[link_idx])
- ) {
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
- DBUG_RETURN(spider_db_errorno(conn));
- }
- } else {
- 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);
- DBUG_RETURN(error_num);
- }
- }
- st_spider_db_request_key request_key;
- request_key.spider_thread_id = spider->trx->spider_thread_id;
- request_key.query_id = spider->trx->thd->query_id;
- request_key.handler = spider;
- request_key.request_id = 1;
- request_key.next = NULL;
- if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num)))
- {
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
- if (error_num || (error_num = spider_db_errorno(conn)))
- DBUG_RETURN(error_num);
- else {
- my_printf_error(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM,
- ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0),
- oracle_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(),
- oracle_share->table_names_str[spider->conn_link_idx[
- link_idx]].ptr());
- DBUG_RETURN(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM);
- }
- }
- 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);
- error_num = res->fetch_table_status(
- sts_mode,
- share->records,
- share->mean_rec_length,
- share->data_file_length,
- share->max_data_file_length,
- share->index_file_length,
- auto_increment_value,
- share->create_time,
- share->update_time,
- share->check_time
- );
- res->free_result();
- delete res;
- if (error_num)
- DBUG_RETURN(error_num);
-*/
if (!share->records)
share->records = 10000;
share->mean_rec_length = 65535;
@@ -11106,9 +11070,12 @@ int spider_oracle_handler::show_table_status(
share->update_time = (time_t) 0;
share->check_time = (time_t) 0;
} else {
+ 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[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;
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
@@ -11132,6 +11099,8 @@ int spider_oracle_handler::show_table_status(
/* retry */
if ((error_num = spider_db_ping(spider, 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);
@@ -11140,6 +11109,8 @@ int spider_oracle_handler::show_table_status(
}
if ((error_num = spider_db_set_names(spider, 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);
@@ -11155,11 +11126,15 @@ int spider_oracle_handler::show_table_status(
-1,
&spider->need_mons[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;
DBUG_RETURN(spider_db_errorno(conn));
}
} 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);
@@ -11175,6 +11150,8 @@ int spider_oracle_handler::show_table_status(
request_key.next = NULL;
if (!(res = conn->db_conn->store_result(NULL, &request_key, &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;
if (error_num || (error_num = spider_db_errorno(conn)))
@@ -11182,6 +11159,8 @@ int spider_oracle_handler::show_table_status(
else
DBUG_RETURN(ER_QUERY_ON_FOREIGN_DATA_SOURCE);
}
+ 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);
@@ -11236,105 +11215,6 @@ int spider_oracle_handler::show_index(
DBUG_PRINT("info",("spider crd_mode=%d", crd_mode));
if (crd_mode == 1)
{
-/*
- pthread_mutex_lock(&conn->mta_conn_mutex);
- SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
- conn->need_mon = &spider->need_mons[link_idx];
- conn->mta_conn_mutex_lock_already = TRUE;
- conn->mta_conn_mutex_unlock_later = TRUE;
- spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
- share);
- if (
- (error_num = spider_db_set_names(spider, conn, link_idx)) ||
- (
- spider_db_query(
- conn,
- oracle_share->show_index[0 + pos].ptr(),
- oracle_share->show_index[0 + pos].length(),
- -1,
- &spider->need_mons[link_idx]) &&
- (error_num = spider_db_errorno(conn))
- )
- ) {
- if (
- error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM &&
- !conn->disable_reconnect
- ) {
-*/
- /* retry */
-/*
- if ((error_num = spider_db_ping(spider, conn, link_idx)))
- {
- 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);
- DBUG_RETURN(error_num);
- }
- if ((error_num = spider_db_set_names(spider, conn, link_idx)))
- {
- 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);
- DBUG_RETURN(error_num);
- }
- spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
- share);
- if (spider_db_query(
- conn,
- oracle_share->show_index[0 + pos].ptr(),
- oracle_share->show_index[0 + pos].length(),
- -1,
- &spider->need_mons[link_idx])
- ) {
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
- DBUG_RETURN(spider_db_errorno(conn));
- }
- } else {
- 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);
- DBUG_RETURN(error_num);
- }
- }
- st_spider_db_request_key request_key;
- request_key.spider_thread_id = spider->trx->spider_thread_id;
- request_key.query_id = spider->trx->thd->query_id;
- request_key.handler = spider;
- request_key.request_id = 1;
- request_key.next = NULL;
- if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num)))
- {
- if (error_num || (error_num = spider_db_errorno(conn)))
- {
- 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);
- DBUG_RETURN(error_num);
- }
-*/
- /* no record is ok */
-/*
- }
- 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);
- if (res)
- {
- error_num = res->fetch_table_cardinality(
- crd_mode,
- table,
- share->cardinality,
- share->cardinality_upd,
- share->bitmap_size
- );
- }
-*/
for (roop_count = 0, tmp_cardinality = share->cardinality;
roop_count < (int) table->s->fields;
roop_count++, tmp_cardinality++)
@@ -11346,19 +11226,13 @@ int spider_oracle_handler::show_index(
*tmp_cardinality = 1;
}
}
-/*
- if (res)
- {
- res->free_result();
- delete res;
- }
- if (error_num)
- DBUG_RETURN(error_num);
-*/
} else {
+ 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[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;
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
@@ -11382,6 +11256,8 @@ int spider_oracle_handler::show_index(
/* retry */
if ((error_num = spider_db_ping(spider, 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);
@@ -11390,6 +11266,8 @@ int spider_oracle_handler::show_index(
}
if ((error_num = spider_db_set_names(spider, 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);
@@ -11405,11 +11283,15 @@ int spider_oracle_handler::show_index(
-1,
&spider->need_mons[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;
DBUG_RETURN(spider_db_errorno(conn));
}
} 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);
@@ -11427,6 +11309,8 @@ int spider_oracle_handler::show_index(
{
if (error_num || (error_num = spider_db_errorno(conn)))
{
+ 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);
@@ -11435,6 +11319,8 @@ int spider_oracle_handler::show_index(
}
/* no record is ok */
}
+ 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);
@@ -11480,9 +11366,12 @@ int spider_oracle_handler::show_records(
SPIDER_SHARE *share = spider->share;
uint pos = spider->conn_link_idx[link_idx];
DBUG_ENTER("spider_oracle_handler::show_records");
+ 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[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;
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
@@ -11506,6 +11395,8 @@ int spider_oracle_handler::show_records(
/* retry */
if ((error_num = spider_db_ping(spider, 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);
@@ -11515,6 +11406,8 @@ int spider_oracle_handler::show_records(
}
if ((error_num = spider_db_set_names(spider, 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);
@@ -11531,12 +11424,16 @@ int spider_oracle_handler::show_records(
-1,
&spider->need_mons[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;
DBUG_PRINT("info", ("spider error_num=%d 3", error_num));
DBUG_RETURN(spider_db_errorno(conn));
}
} 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);
@@ -11553,18 +11450,29 @@ int spider_oracle_handler::show_records(
request_key.next = NULL;
if (!(res = conn->db_conn->store_result(NULL, &request_key, &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;
- if (error_num || (error_num = spider_db_errorno(conn)))
+ if (error_num)
{
+ SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
+ pthread_mutex_unlock(&conn->mta_conn_mutex);
DBUG_PRINT("info", ("spider error_num=%d 5", error_num));
DBUG_RETURN(error_num);
+ }
+ else if (error_num || (error_num = spider_db_errorno(conn)))
+ {
+ DBUG_PRINT("info", ("spider error_num=%d 6", error_num));
+ DBUG_RETURN(error_num);
} else {
- DBUG_PRINT("info", ("spider error_num=%d 6",
+ DBUG_PRINT("info", ("spider error_num=%d 7",
ER_QUERY_ON_FOREIGN_DATA_SOURCE));
DBUG_RETURN(ER_QUERY_ON_FOREIGN_DATA_SOURCE);
}
}
+ 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);
@@ -11597,9 +11505,12 @@ int spider_oracle_handler::show_autoinc(
if (!oracle_share->show_autoinc)
DBUG_RETURN(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 = &spider->need_mons[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;
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
@@ -11623,6 +11534,8 @@ int spider_oracle_handler::show_autoinc(
/* retry */
if ((error_num = spider_db_ping(spider, 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);
@@ -11632,6 +11545,8 @@ int spider_oracle_handler::show_autoinc(
}
if ((error_num = spider_db_set_names(spider, 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);
@@ -11648,12 +11563,16 @@ int spider_oracle_handler::show_autoinc(
-1,
&spider->need_mons[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;
DBUG_PRINT("info", ("spider error_num=%d 3", error_num));
DBUG_RETURN(spider_db_errorno(conn));
}
} 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);
@@ -11670,18 +11589,29 @@ int spider_oracle_handler::show_autoinc(
request_key.next = NULL;
if (!(res = conn->db_conn->store_result(NULL, &request_key, &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;
- if (error_num || (error_num = spider_db_errorno(conn)))
+ if (error_num)
{
+ SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
+ pthread_mutex_unlock(&conn->mta_conn_mutex);
DBUG_PRINT("info", ("spider error_num=%d 5", error_num));
DBUG_RETURN(error_num);
+ }
+ else if ((error_num = spider_db_errorno(conn)))
+ {
+ DBUG_PRINT("info", ("spider error_num=%d 6", error_num));
+ DBUG_RETURN(error_num);
} else {
- DBUG_PRINT("info", ("spider error_num=%d 6",
+ DBUG_PRINT("info", ("spider error_num=%d 7",
ER_QUERY_ON_FOREIGN_DATA_SOURCE));
DBUG_RETURN(ER_QUERY_ON_FOREIGN_DATA_SOURCE);
}
}
+ 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);
@@ -11791,9 +11721,12 @@ ha_rows spider_oracle_handler::explain_select(
DBUG_RETURN(HA_POS_ERROR);
}
+ 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[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;
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
@@ -11819,6 +11752,8 @@ ha_rows spider_oracle_handler::explain_select(
{
if (spider->check_error_mode(error_num))
my_errno = 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);
@@ -11829,6 +11764,8 @@ ha_rows spider_oracle_handler::explain_select(
{
if (spider->check_error_mode(error_num))
my_errno = 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);
@@ -11847,6 +11784,8 @@ ha_rows spider_oracle_handler::explain_select(
error_num = spider_db_errorno(conn);
if (spider->check_error_mode(error_num))
my_errno = 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);
@@ -11856,6 +11795,8 @@ ha_rows spider_oracle_handler::explain_select(
} else {
if (spider->check_error_mode(error_num))
my_errno = 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);
@@ -11875,6 +11816,8 @@ ha_rows spider_oracle_handler::explain_select(
{
if (spider->check_error_mode(error_num))
my_errno = 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);
@@ -11882,6 +11825,8 @@ ha_rows spider_oracle_handler::explain_select(
DBUG_RETURN(HA_POS_ERROR);
} else {
my_errno = ER_QUERY_ON_FOREIGN_DATA_SOURCE;
+ 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);
@@ -11889,6 +11834,8 @@ ha_rows spider_oracle_handler::explain_select(
DBUG_RETURN(HA_POS_ERROR);
}
}
+ 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);
@@ -11922,13 +11869,18 @@ int spider_oracle_handler::lock_tables(
}
if (str->length())
{
+ 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[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;
if ((error_num = spider_db_set_names(spider, 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);
@@ -11944,10 +11896,14 @@ int spider_oracle_handler::lock_tables(
-1,
&spider->need_mons[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;
DBUG_RETURN(spider_db_errorno(conn));
}
+ 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);
@@ -11993,13 +11949,18 @@ int spider_oracle_handler::disable_keys(
{
DBUG_RETURN(error_num);
}
+ 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[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;
if ((error_num = spider_db_set_names(spider, 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);
@@ -12015,11 +11976,15 @@ int spider_oracle_handler::disable_keys(
-1,
&spider->need_mons[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;
error_num = spider_db_errorno(conn);
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);
@@ -12042,13 +12007,18 @@ int spider_oracle_handler::enable_keys(
{
DBUG_RETURN(error_num);
}
+ 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[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;
if ((error_num = spider_db_set_names(spider, 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);
@@ -12064,11 +12034,15 @@ int spider_oracle_handler::enable_keys(
-1,
&spider->need_mons[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;
error_num = spider_db_errorno(conn);
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);
@@ -12092,13 +12066,18 @@ int spider_oracle_handler::check_table(
{
DBUG_RETURN(error_num);
}
+ 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[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;
if ((error_num = spider_db_set_names(spider, 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);
@@ -12114,11 +12093,15 @@ int spider_oracle_handler::check_table(
-1,
&spider->need_mons[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;
error_num = spider_db_errorno(conn);
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);
@@ -12142,13 +12125,18 @@ int spider_oracle_handler::repair_table(
{
DBUG_RETURN(error_num);
}
+ 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[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;
if ((error_num = spider_db_set_names(spider, 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);
@@ -12164,11 +12152,15 @@ int spider_oracle_handler::repair_table(
-1,
&spider->need_mons[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;
error_num = spider_db_errorno(conn);
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);
@@ -12191,13 +12183,18 @@ int spider_oracle_handler::analyze_table(
{
DBUG_RETURN(error_num);
}
+ 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[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;
if ((error_num = spider_db_set_names(spider, 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);
@@ -12213,11 +12210,15 @@ int spider_oracle_handler::analyze_table(
-1,
&spider->need_mons[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;
error_num = spider_db_errorno(conn);
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);
@@ -12240,13 +12241,18 @@ int spider_oracle_handler::optimize_table(
{
DBUG_RETURN(error_num);
}
+ 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[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;
if ((error_num = spider_db_set_names(spider, 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);
@@ -12262,11 +12268,15 @@ int spider_oracle_handler::optimize_table(
-1,
&spider->need_mons[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;
error_num = spider_db_errorno(conn);
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);
@@ -12292,6 +12302,14 @@ int spider_oracle_handler::flush_tables(
}
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
share);
+ 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[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;
if (spider_db_query(
conn,
str->ptr(),
@@ -12299,9 +12317,17 @@ int spider_oracle_handler::flush_tables(
-1,
&spider->need_mons[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;
error_num = spider_db_errorno(conn);
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);
pthread_mutex_unlock(&conn->mta_conn_mutex);
DBUG_RETURN(0);
@@ -12317,6 +12343,14 @@ int spider_oracle_handler::flush_logs(
DBUG_PRINT("info",("spider this=%p", this));
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
share);
+ 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[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;
if (spider_db_query(
conn,
SPIDER_SQL_FLUSH_LOGS_STR,
@@ -12324,9 +12358,17 @@ int spider_oracle_handler::flush_logs(
-1,
&spider->need_mons[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;
error_num = spider_db_errorno(conn);
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);
pthread_mutex_unlock(&conn->mta_conn_mutex);
DBUG_RETURN(0);
diff --git a/storage/spider/spd_group_by_handler.cc b/storage/spider/spd_group_by_handler.cc
index 3b57092c4ce..c83ee753e5b 100644
--- a/storage/spider/spd_group_by_handler.cc
+++ b/storage/spider/spd_group_by_handler.cc
@@ -1410,6 +1410,7 @@ int spider_group_by_handler::init_scan()
}
} else {
#endif
+ pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
if (dbton_hdl->need_lock_before_set_sql_for_exec(
SPIDER_SQL_TYPE_SELECT_SQL))
{
@@ -1420,6 +1421,12 @@ int spider_group_by_handler::init_scan()
dbton_hdl->set_sql_for_exec(SPIDER_SQL_TYPE_SELECT_SQL, link_idx,
link_idx_chain)))
{
+ 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(
@@ -1429,11 +1436,15 @@ int spider_group_by_handler::init_scan()
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
}
conn->need_mon = &spider->need_mons[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;
if ((error_num = spider_db_set_names(spider, 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);
@@ -1458,6 +1469,8 @@ int spider_group_by_handler::init_scan()
spider->result_list.quick_mode,
&spider->need_mons[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;
error_num = spider_db_errorno(conn);
@@ -1474,6 +1487,8 @@ int spider_group_by_handler::init_scan()
DBUG_RETURN(error_num);
}
spider->connection_ids[link_idx] = 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 (fields->is_first_link_ok_chain(link_idx_chain))
diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h
index c32b476b474..b0a3dae72ba 100644
--- a/storage/spider/spd_include.h
+++ b/storage/spider/spd_include.h
@@ -18,6 +18,8 @@
#if MYSQL_VERSION_ID < 50500
#define spider_my_free(A,B) my_free(A,B)
+#define pthread_mutex_assert_owner(A)
+#define pthread_mutex_assert_not_owner(A)
#else
#define spider_my_free(A,B) my_free(A)
#ifdef pthread_mutex_t
@@ -40,6 +42,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
diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc
index 83c5a37555f..ca3b7fa08ed 100644
--- a/storage/spider/spd_table.cc
+++ b/storage/spider/spd_table.cc
@@ -6355,13 +6355,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);
@@ -6374,6 +6379,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);