diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 0510e537210..f1bf402fe71 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -109,6 +109,8 @@ static const char *name_quote_str = SPIDER_SQL_NAME_QUOTE_STR; #define SPIDER_SQL_SHOW_TABLE_STATUS_LEN sizeof(SPIDER_SQL_SHOW_TABLE_STATUS_STR) - 1 #define SPIDER_SQL_SELECT_TABLES_STATUS_STR "select `table_rows`,`avg_row_length`,`data_length`,`max_data_length`,`index_length`,`auto_increment`,`create_time`,`update_time`,`check_time` from `information_schema`.`tables` where `table_schema` = " #define SPIDER_SQL_SELECT_TABLES_STATUS_LEN sizeof(SPIDER_SQL_SELECT_TABLES_STATUS_STR) - 1 +#define SPIDER_SQL_SHOW_WARNINGS_STR "show warnings" +#define SPIDER_SQL_SHOW_WARNINGS_LEN sizeof(SPIDER_SQL_SHOW_WARNINGS_STR) - 1 #ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE #define SPIDER_SQL_SHOW_COLUMNS_STR "show columns from " @@ -1553,6 +1555,8 @@ int spider_db_mysql::exec_query( conn->tgt_host, db_conn->thread_id, current_thd->thread_id, db_conn->affected_rows, db_conn->insert_id, db_conn->server_status, db_conn->warning_count); + if (spider_param_log_result_errors() >= 3) + print_warnings(l_time); } else if (spider_param_log_result_errors() >= 4) { time_t cur_time = (time_t) time((time_t*) 0); @@ -1633,6 +1637,78 @@ bool spider_db_mysql::is_xa_nota_error( DBUG_RETURN(xa_nota); } +void spider_db_mysql::print_warnings( + struct tm *l_time +) { + DBUG_ENTER("spider_db_mysql::print_warnings"); + DBUG_PRINT("info",("spider this=%p", this)); + if (db_conn->status == MYSQL_STATUS_READY) + { +#if MYSQL_VERSION_ID < 50500 + if (!(db_conn->last_used_con->server_status & SERVER_MORE_RESULTS_EXISTS)) +#else + 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 (!mysql_real_query(db_conn, SPIDER_SQL_SHOW_WARNINGS_STR, + SPIDER_SQL_SHOW_WARNINGS_LEN)) + { + MYSQL_RES *res; + MYSQL_ROW row = NULL; + uint num_fields; + if ( + !(res = mysql_store_result(db_conn)) || + !(row = mysql_fetch_row(res)) + ) { + if (mysql_errno(db_conn)) + { + 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) + { + mysql_free_result(res); + DBUG_VOID_RETURN; + } + while (row) + { + fprintf(stderr, "%04d%02d%02d %02d:%02d:%02d [WARN SPIDER RESULT] " + "from [%s] %ld to %ld: %s %s %s\n", + l_time->tm_year + 1900, l_time->tm_mon + 1, l_time->tm_mday, + l_time->tm_hour, l_time->tm_min, l_time->tm_sec, + conn->tgt_host, db_conn->thread_id, + current_thd->thread_id, row[0], row[1], row[2]); + row = mysql_fetch_row(res); + } + if (res) + mysql_free_result(res); + } else { +/* + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); +*/ + } + } + } + DBUG_VOID_RETURN; +} + spider_db_result *spider_db_mysql::store_result( spider_db_result_buffer **spider_res_buf, st_spider_db_request_key *request_key, diff --git a/storage/spider/spd_db_mysql.h b/storage/spider/spd_db_mysql.h index 07f8e265471..da1eeeb11c5 100644 --- a/storage/spider/spd_db_mysql.h +++ b/storage/spider/spd_db_mysql.h @@ -271,6 +271,9 @@ public: bool is_xa_nota_error( int error_num ); + void print_warnings( + struct tm *l_time + ); spider_db_result *store_result( spider_db_result_buffer **spider_res_buf, st_spider_db_request_key *request_key, diff --git a/storage/spider/spd_err.h b/storage/spider/spd_err.h index c644d6ebca5..e025a0156d3 100644 --- a/storage/spider/spd_err.h +++ b/storage/spider/spd_err.h @@ -61,6 +61,8 @@ #define ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_STR "Can't use wrapper '%s' for NOSQL connection" #define ER_SPIDER_REQUEST_KEY_NUM 12523 #define ER_SPIDER_REQUEST_KEY_STR "Request key not found" +#define ER_SPIDER_CANT_OPEN_SYS_TABLE_NUM 12524 +#define ER_SPIDER_CANT_OPEN_SYS_TABLE_STR "Can't open system table %s.%s" #define ER_SPIDER_CANT_USE_BOTH_INNER_XA_AND_SNAPSHOT_NUM 12601 #define ER_SPIDER_CANT_USE_BOTH_INNER_XA_AND_SNAPSHOT_STR "Can't use both spider_use_consistent_snapshot = 1 and spider_internal_xa = 1" diff --git a/storage/spider/spd_sys_table.cc b/storage/spider/spd_sys_table.cc index 24fa5ff6faa..272546d0753 100644 --- a/storage/spider/spd_sys_table.cc +++ b/storage/spider/spd_sys_table.cc @@ -90,7 +90,10 @@ TABLE *spider_open_sys_table( if (!(table = spider_sys_open_table(thd, &tables, open_tables_backup))) #endif { - *error_num = my_errno; + my_printf_error(ER_SPIDER_CANT_OPEN_SYS_TABLE_NUM, + ER_SPIDER_CANT_OPEN_SYS_TABLE_STR, MYF(0), + "mysql", table_name); + *error_num = ER_SPIDER_CANT_OPEN_SYS_TABLE_NUM; DBUG_RETURN(NULL); } #if MYSQL_VERSION_ID < 50500 @@ -117,7 +120,10 @@ TABLE *spider_open_sys_table( table, FALSE) ) { release_table_share(table_share, RELEASE_NORMAL); - *error_num = my_errno; + my_printf_error(ER_SPIDER_CANT_OPEN_SYS_TABLE_NUM, + ER_SPIDER_CANT_OPEN_SYS_TABLE_STR, MYF(0), + "mysql", table_name); + *error_num = ER_SPIDER_CANT_OPEN_SYS_TABLE_NUM; goto error; } } @@ -1913,7 +1919,6 @@ int spider_sys_update_tables_link_status( SPIDER_SYS_TABLES_TABLE_NAME_LEN, TRUE, &open_tables_backup, need_lock, &error_num)) ) { - my_error(error_num, MYF(0)); goto error; } if ((error_num = spider_update_tables_link_status(table_tables, @@ -1952,7 +1957,6 @@ int spider_sys_log_tables_link_failed( SPIDER_SYS_LINK_FAILED_TABLE_NAME_LEN, TRUE, &open_tables_backup, need_lock, &error_num)) ) { - my_error(error_num, MYF(0)); goto error; } empty_record(table_tables); @@ -1992,7 +1996,6 @@ int spider_sys_log_xa_failed( SPIDER_SYS_XA_FAILED_TABLE_NAME_LEN, TRUE, &open_tables_backup, need_lock, &error_num)) ) { - my_error(error_num, MYF(0)); goto error; } empty_record(table_tables); diff --git a/storage/spider/spd_trx.cc b/storage/spider/spd_trx.cc index 7dac85180fd..1af47d0e70b 100644 --- a/storage/spider/spd_trx.cc +++ b/storage/spider/spd_trx.cc @@ -1907,6 +1907,8 @@ int spider_internal_xa_commit( if ((conn = spider_tree_first(trx->join_trx_top))) { do { + if (conn->bg_search) + spider_bg_conn_break(conn, NULL); DBUG_PRINT("info",("spider conn=%p", conn)); DBUG_PRINT("info",("spider conn->join_trx=%u", conn->join_trx)); if (conn->join_trx) @@ -2087,6 +2089,8 @@ int spider_internal_xa_rollback( if ((conn = spider_tree_first(trx->join_trx_top))) { do { + if (conn->bg_search) + spider_bg_conn_break(conn, NULL); if (conn->join_trx) { if (conn->disable_xa) @@ -2271,6 +2275,8 @@ int spider_internal_xa_prepare( if ((conn = spider_tree_first(trx->join_trx_top))) { do { + if (conn->bg_search) + spider_bg_conn_break(conn, NULL); if (conn->disable_xa) { if (conn->table_lock != 3)