Commit a8c57172 authored by Yuchen Pei's avatar Yuchen Pei

Merge branch '10.6' into 10.11

parents b168859d 09b1269e
......@@ -738,8 +738,8 @@ static int check_options(int argc, char **argv, char *operation)
{
int i= 0; /* loop counter */
int num_found= 0; /* number of options found (shortcut loop) */
char config_file[FN_REFLEN]; /* configuration file name */
char plugin_name[FN_REFLEN]; /* plugin name */
char config_file[FN_REFLEN+1]; /* configuration file name */
char plugin_name[FN_REFLEN+1]; /* plugin name */
/* Form prefix strings for the options. */
const char *basedir_prefix = "--basedir=";
......@@ -787,8 +787,8 @@ static int check_options(int argc, char **argv, char *operation)
/* read the plugin config file and check for match against argument */
else
{
if (safe_strcpy_truncated(plugin_name, sizeof plugin_name, argv[i]) ||
safe_strcpy_truncated(config_file, sizeof config_file, argv[i]) ||
if (safe_strcpy_truncated(plugin_name, sizeof(plugin_name)-1, argv[i]) ||
safe_strcpy_truncated(config_file, sizeof(config_file)-1, argv[i]) ||
safe_strcat(config_file, sizeof(config_file), ".ini"))
{
fprintf(stderr, "ERROR: argument is too long.\n");
......
# Mask the cost value from any field that looks like
# "xxx_cost" : double_number
# Print the
# "xxx_cost" : "REPLACED"
# instead
--replace_regex /(_cost": )[0-9.e-]+/\1"REPLACED"/
#--replace_regex /(_cost": )[0-9.e-]+/"REPLACED"/
#--replace_regex /[0-9]+/BBB/
#--replace_regex /("r_engine_stats":) {[^}]*}/\1 REPLACED/
......@@ -109,9 +109,9 @@ JS
}
],
"can_skip_filesort": true,
"full_join_cost": 46064.98442,
"full_join_cost": "REPLACED",
"risk_ratio": 10,
"shortcut_join_cost": 97.28224614,
"shortcut_join_cost": "REPLACED",
"shortcut_cost_with_risk": 972.8224614,
"use_shortcut_cost": true
}
......@@ -161,9 +161,9 @@ JS
"test_if_skip_sort_order_early":
[],
"can_skip_filesort": false,
"full_join_cost": 46064.98442,
"full_join_cost": "REPLACED",
"risk_ratio": 10,
"shortcut_join_cost": 2097.281246,
"shortcut_join_cost": "REPLACED",
"shortcut_cost_with_risk": 20972.81246,
"use_shortcut_cost": true
}
......@@ -246,9 +246,9 @@ JS
}
],
"can_skip_filesort": false,
"full_join_cost": 46064.98442,
"full_join_cost": "REPLACED",
"risk_ratio": 10,
"shortcut_join_cost": 24059.12698,
"shortcut_join_cost": "REPLACED",
"shortcut_cost_with_risk": 240591.2698,
"use_shortcut_cost": false
}
......@@ -366,9 +366,9 @@ JS
}
],
"can_skip_filesort": true,
"full_join_cost": 47079.71684,
"full_join_cost": "REPLACED",
"risk_ratio": 10,
"shortcut_join_cost": 98.29697856,
"shortcut_join_cost": "REPLACED",
"shortcut_cost_with_risk": 982.9697856,
"use_shortcut_cost": true
}
......@@ -452,9 +452,9 @@ JS
}
],
"can_skip_filesort": true,
"full_join_cost": 46064.98442,
"full_join_cost": "REPLACED",
"risk_ratio": 10,
"shortcut_join_cost": 97.28224614,
"shortcut_join_cost": "REPLACED",
"shortcut_cost_with_risk": 972.8224614,
"use_shortcut_cost": true
}
......
......@@ -68,6 +68,7 @@ set optimizer_join_limit_pref_ratio=10;
eval $query;
set @trace=(select trace from information_schema.optimizer_trace);
--source include/optimizer_trace_no_costs.inc
select json_detailed(json_extract(@trace, '$**.join_limit_shortcut_choice')) as JS;
--echo #
......@@ -95,6 +96,7 @@ set optimizer_join_limit_pref_ratio=10;
eval $query;
set @trace=(select trace from information_schema.optimizer_trace);
--source include/optimizer_trace_no_costs.inc
select json_detailed(json_extract(@trace, '$**.join_limit_shortcut_choice')) as JS;
--echo #
......@@ -121,6 +123,7 @@ set optimizer_join_limit_pref_ratio=10;
eval $query;
set @trace=(select trace from information_schema.optimizer_trace);
--source include/optimizer_trace_no_costs.inc
select json_detailed(json_extract(@trace, '$**.join_limit_shortcut_choice')) as JS;
--echo #
......@@ -140,6 +143,7 @@ limit 10;
set @trace=(select trace from information_schema.optimizer_trace);
--echo # This will show nothing as limit shortcut code figures that
--echo # it's not possible to use t1 to construct shortcuts:
--source include/optimizer_trace_no_costs.inc
select json_detailed(json_extract(@trace, '$**.join_limit_shortcut_choice')) as JS;
--echo #
......@@ -169,6 +173,7 @@ set optimizer_join_limit_pref_ratio=10;
eval $query;
set @trace=(select trace from information_schema.optimizer_trace);
--source include/optimizer_trace_no_costs.inc
select json_detailed(json_extract(@trace, '$**.join_limit_shortcut_choice')) as JS;
--echo #
......@@ -197,6 +202,7 @@ set optimizer_join_limit_pref_ratio=10;
eval $query;
set @trace=(select trace from information_schema.optimizer_trace);
--source include/optimizer_trace_no_costs.inc
select json_detailed(json_extract(@trace, '$**.join_limit_shortcut_choice')) as JS;
......
......@@ -130,16 +130,19 @@ s3_block_size X
s3_bucket X
s3_debug X
s3_host_name X
s3_no_content_type X
s3_pagecache_age_threshold X
s3_pagecache_buffer_size X
s3_pagecache_division_limit X
s3_pagecache_file_hash_size X
s3_port X
s3_protocol_version X
s3_provider X
s3_region X
s3_replicate_alter_as_create_select X
s3_secret_key X
s3_slave_ignore_updates X
s3_ssl_no_verify X
s3_use_http X
show variables like "s3_slave%";
Variable_name Value
......
......@@ -12,6 +12,8 @@ s3-secret-key=@ENV.S3_SECRET_KEY
s3-region=@ENV.S3_REGION
s3-port=@ENV.S3_PORT
s3-use-http=@ENV.S3_USE_HTTP
s3-ssl-no-verify=@ENV.S3_SSL_NO_VERIFY
s3-provider=@ENV.S3_PROVIDER
#s3-host-name=s3.amazonaws.com
#s3-protocol-version=Amazon
......
......@@ -10,6 +10,8 @@ s3-secret-key=@ENV.S3_SECRET_KEY
s3-region=@ENV.S3_REGION
s3-port=@ENV.S3_PORT
s3-use-http=@ENV.S3_USE_HTTP
s3-ssl-no-verify=@ENV.S3_SSL_NO_VERIFY
s3-provider=@ENV.S3_PROVIDER
# You can change the following when running the tests against
# your own S3 setup
......
......@@ -20,6 +20,8 @@ if(connect(SOCK, $paddr))
$ENV{'S3_REGION'} = "";
$ENV{'S3_PROTOCOL_VERSION'} = "Auto";
$ENV{'S3_USE_HTTP'} = "ON";
$ENV{'S3_SSL_NO_VERIFY'} = "OFF";
$ENV{'S3_PROVIDER'} = "Default";
}
else
{
......@@ -62,6 +64,17 @@ else
{
$ENV{'S3_USE_HTTP'} = "OFF";
}
if (!$ENV{'S3_SSL_NO_VERIFY'})
{
$ENV{'S3_SSL_NO_VERIFY'} = "OFF";
}
if (!$ENV{'S3_PROVIDER'})
{
$ENV{'S3_PROVIDER'} = "Default";
}
}
bless { };
......@@ -41,7 +41,10 @@ static const char *opt_database;
static const char *opt_s3_bucket="MariaDB";
static my_bool opt_compression, opt_verbose, opt_force, opt_s3_debug;
static my_bool opt_s3_use_http;
static my_bool opt_s3_ssl_no_verify;
static my_bool opt_s3_no_content_type;
static ulong opt_operation= OP_IMPOSSIBLE, opt_protocol_version= 1;
static ulong opt_provider= 0;
static ulong opt_block_size;
static ulong opt_s3_port;
static char **default_argv=0;
......@@ -73,6 +76,13 @@ static struct my_option my_long_options[] =
{"s3_use_http", 'P', "If true, force use of HTTP protocol",
(char**) &opt_s3_use_http, (char**) &opt_s3_use_http,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"s3_ssl_no_verify", 's', "If true, verification of the S3 endpoint SSL "
"certificate is disabled",
(char**) &opt_s3_ssl_no_verify, (char**) &opt_s3_ssl_no_verify,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"s3_no_content_type", 'n', "If true, disables the Content-Type header",
(char**) &opt_s3_no_content_type, (char**) &opt_s3_no_content_type,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"compress", 'c', "Use compression", &opt_compression, &opt_compression,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"op", 'o', "Operation to execute. One of 'from_s3', 'to_s3' or "
......@@ -92,6 +102,10 @@ static struct my_option my_long_options[] =
"Note: \"Legacy\", \"Original\" and \"Amazon\" are deprecated.",
&opt_protocol_version, &opt_protocol_version, &s3_protocol_typelib,
GET_ENUM, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"s3_provider", 'R', "Enable S3 provider specific compatibility tweaks "
"\"Default\", \"Amazon\", or \"Huawei\".",
&opt_provider, &opt_provider, &s3_provider_typelib,
GET_ENUM, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"force", 'f', "Force copy even if target exists",
&opt_force, &opt_force, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"verbose", 'v', "Write more information", &opt_verbose, &opt_verbose,
......@@ -220,6 +234,19 @@ int main(int argc, char** argv)
ms3_set_option(global_s3_client, MS3_OPT_BUFFER_CHUNK_SIZE, &block_size);
/* Provider specific overrides */
switch (opt_provider)
{
case 0: /* Default */
break;
case 1: /* Amazon */
opt_protocol_version = 5;
break;
case 2: /* Huawei */
opt_s3_no_content_type = 1;
break;
}
if (opt_protocol_version > 2)
{
uint8_t protocol_version;
......@@ -245,6 +272,11 @@ int main(int argc, char** argv)
if (opt_s3_use_http)
ms3_set_option(global_s3_client, MS3_OPT_USE_HTTP, NULL);
if (opt_s3_ssl_no_verify)
ms3_set_option(global_s3_client, MS3_OPT_DISABLE_SSL_VERIFY, NULL);
if (opt_s3_no_content_type)
ms3_set_option(global_s3_client, MS3_OPT_NO_CONTENT_TYPE, NULL);
for (; *argv ; argv++)
{
......
......@@ -78,7 +78,7 @@
#define DEFAULT_AWS_HOST_NAME "s3.amazonaws.com"
static PAGECACHE s3_pagecache;
static ulong s3_block_size, s3_protocol_version;
static ulong s3_block_size, s3_protocol_version, s3_provider;
static ulong s3_pagecache_division_limit, s3_pagecache_age_threshold;
static ulong s3_pagecache_file_hash_size;
static ulonglong s3_pagecache_buffer_size;
......@@ -86,6 +86,8 @@ static char *s3_bucket, *s3_access_key=0, *s3_secret_key=0, *s3_region;
static char *s3_host_name;
static int s3_port;
static my_bool s3_use_http;
static my_bool s3_ssl_no_verify;
static my_bool s3_no_content_type;
static char *s3_tmp_access_key=0, *s3_tmp_secret_key=0;
static my_bool s3_debug= 0, s3_slave_ignore_updates= 0;
static my_bool s3_replicate_alter_as_create_select= 0;
......@@ -222,6 +224,10 @@ static MYSQL_SYSVAR_BOOL(use_http, s3_use_http,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"If true, force use of HTTP protocol",
NULL /*check*/, NULL /*update*/, 0 /*default*/);
static MYSQL_SYSVAR_BOOL(ssl_no_verify, s3_ssl_no_verify,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"If true, SSL certificate verifiction for the S3 endpoint is disabled",
NULL, NULL, 0);
static MYSQL_SYSVAR_STR(access_key, s3_tmp_access_key,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY | PLUGIN_VAR_MEMALLOC,
"AWS access key",
......@@ -234,6 +240,15 @@ static MYSQL_SYSVAR_STR(region, s3_region,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"AWS region",
0, 0, "");
static MYSQL_SYSVAR_BOOL(no_content_type, s3_no_content_type,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"If true, disables the Content-Type header, required for some providers",
NULL, NULL, 0);
static MYSQL_SYSVAR_ENUM(provider, s3_provider,
PLUGIN_VAR_RQCMDARG,
"Enable S3 provider specific compatibility tweaks "
"\"Default\", \"Amazon\", or \"Huawei\". ",
NULL, NULL, 0, &s3_provider_typelib);
ha_create_table_option s3_table_option_list[]=
{
......@@ -319,6 +334,9 @@ static my_bool s3_info_init(S3_INFO *info)
lex_string_set(&info->host_name, s3_host_name);
info->port= s3_port;
info->use_http= s3_use_http;
info->ssl_no_verify= s3_ssl_no_verify;
info->no_content_type = s3_no_content_type;
info->provider= s3_provider;
lex_string_set(&info->access_key, s3_access_key);
lex_string_set(&info->secret_key, s3_secret_key);
lex_string_set(&info->region, s3_region);
......@@ -1120,12 +1138,15 @@ static struct st_mysql_sys_var* system_variables[]= {
MYSQL_SYSVAR(host_name),
MYSQL_SYSVAR(port),
MYSQL_SYSVAR(use_http),
MYSQL_SYSVAR(ssl_no_verify),
MYSQL_SYSVAR(bucket),
MYSQL_SYSVAR(access_key),
MYSQL_SYSVAR(secret_key),
MYSQL_SYSVAR(region),
MYSQL_SYSVAR(slave_ignore_updates),
MYSQL_SYSVAR(replicate_alter_as_create_select),
MYSQL_SYSVAR(no_content_type),
MYSQL_SYSVAR(provider),
NULL
};
......
Subproject commit a81724ab07bd28e16bf431419c24b6362d5894fc
Subproject commit 5e6aa32f96ebdbcaf32b90d6182685156f8198b5
......@@ -43,6 +43,9 @@ static const char *protocol_types[]= {"Auto", "Original", "Amazon", "Legacy", "P
TYPELIB s3_protocol_typelib= {array_elements(protocol_types)-1,"",
protocol_types, NULL};
static const char *providers[]= {"Default", "Amazon", "Huawei", NullS};
TYPELIB s3_provider_typelib = {array_elements(providers)-1,"",providers, NULL};
/******************************************************************************
Allocations handler for libmarias3
To be removed when we do the init allocation in mysqld.cc
......@@ -154,6 +157,20 @@ ms3_st *s3_open_connection(S3_INFO *s3)
errno, ms3_error(errno));
my_errno= HA_ERR_NO_SUCH_TABLE;
}
/* Provider specific overrides */
switch (s3->provider)
{
case 0: /* Default */
break;
case 1: /* Amazon */
s3->protocol_version = 5;
break;
case 2: /* Huawei */
s3->no_content_type = 1;
break;
}
if (s3->protocol_version > 2)
{
uint8_t protocol_version;
......@@ -177,6 +194,12 @@ ms3_st *s3_open_connection(S3_INFO *s3)
if (s3->use_http)
ms3_set_option(s3_client, MS3_OPT_USE_HTTP, NULL);
if (s3->ssl_no_verify)
ms3_set_option(s3_client, MS3_OPT_DISABLE_SSL_VERIFY, NULL);
if (s3->no_content_type)
ms3_set_option(s3_client, MS3_OPT_NO_CONTENT_TYPE, NULL);
return s3_client;
}
......
......@@ -38,6 +38,7 @@ extern struct s3_func {
} s3f;
extern TYPELIB s3_protocol_typelib;
extern TYPELIB s3_provider_typelib;
/* Store information about a s3 connection */
......@@ -47,6 +48,8 @@ struct s3_info
LEX_CSTRING access_key, secret_key, region, bucket, host_name;
int port; // 0 means 'Use default'
my_bool use_http;
my_bool ssl_no_verify;
my_bool no_content_type;
/* Will be set by caller or by ma_open() */
LEX_CSTRING database, table;
......@@ -63,6 +66,8 @@ struct s3_info
/* Protocol for the list bucket API call. 1 for Amazon, 2 for some others */
uint8_t protocol_version;
uint8_t provider;
};
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -271,7 +271,6 @@ int spider_free_conn_alloc(
conn->db_conn = NULL;
}
spider_conn_done(conn);
DBUG_ASSERT(!conn->mta_conn_mutex_file_pos.file_name);
pthread_mutex_destroy(&conn->mta_conn_mutex);
conn->default_database.free();
DBUG_RETURN(0);
......@@ -1467,10 +1466,6 @@ void spider_conn_clear_queue(
) {
DBUG_ENTER("spider_conn_clear_queue");
DBUG_PRINT("info", ("spider conn=%p", conn));
/*
conn->queued_connect = FALSE;
conn->queued_ping = FALSE;
*/
conn->queued_trx_isolation = FALSE;
conn->queued_semi_trx_isolation = FALSE;
conn->queued_autocommit = FALSE;
......@@ -2534,7 +2529,6 @@ void *spider_bg_conn_action(
) {
ulong sql_type;
sql_type= SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_TMP_SQL;
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
if (spider->use_fields)
{
if ((error_num = dbton_handler->set_sql_for_exec(sql_type,
......@@ -2553,17 +2547,12 @@ void *spider_bg_conn_action(
strmov(result_list->bgs_error_msg, spider_stmt_da_message(thd));
}
}
pthread_mutex_lock(&conn->mta_conn_mutex);
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
/* todo: is it ok if the following statement is not locked? */
sql_type &= ~SPIDER_SQL_TYPE_TMP_SQL;
DBUG_PRINT("info",("spider sql_type=%lu", sql_type));
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;
spider_lock_before_query(conn, &spider->need_mons[conn->link_idx]);
if (!(result_list->bgs_error =
spider_db_set_names(spider, conn, conn->link_idx)))
{
......@@ -2632,15 +2621,7 @@ void *spider_bg_conn_action(
strmov(result_list->bgs_error_msg,
spider_stmt_da_message(thd));
}
DBUG_ASSERT(conn->mta_conn_mutex_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 {
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
spider_unlock_after_query(conn, 0);
}
} else {
spider->connection_ids[conn->link_idx] = conn->connection_id;
......@@ -2715,26 +2696,14 @@ 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;
spider_lock_before_query(conn, &spider->need_mons[conn->link_idx]);
*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);
spider_unlock_after_query(conn, 0);
conn->bg_exec_sql = FALSE;
continue;
}
......@@ -4005,3 +3974,42 @@ void spider_free_ipport_conn(void *info)
}
DBUG_VOID_RETURN;
}
void spider_lock_before_query(SPIDER_CONN *conn, int *need_mon)
{
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
pthread_mutex_lock(&conn->mta_conn_mutex);
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;
}
int spider_unlock_after_query(SPIDER_CONN *conn, int ret)
{
DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
conn->mta_conn_mutex_lock_already = FALSE;
conn->mta_conn_mutex_unlock_later = FALSE;
pthread_mutex_unlock(&conn->mta_conn_mutex);
return ret;
}
int spider_unlock_after_query_1(SPIDER_CONN *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;
return spider_db_errorno(conn);
}
int spider_unlock_after_query_2(SPIDER_CONN *conn, ha_spider *spider, int link_idx, TABLE *table)
{
DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
conn->mta_conn_mutex_lock_already = FALSE;
conn->mta_conn_mutex_unlock_later = FALSE;
return spider_db_store_result(spider, link_idx, table);
}
......@@ -24,6 +24,8 @@
#define SPIDER_SIMPLE_RECORDS 3
#define SPIDER_SIMPLE_CHECKSUM_TABLE 4
struct TABLE;
/*
The SPIDER_CONN_LOOP_CHECK has been added to the loop_check queue to
check for self-reference.
......@@ -440,3 +442,11 @@ SPIDER_CONN* spider_get_conn_from_idle_connection
int *error_num
);
void spider_free_ipport_conn(void *info);
void spider_lock_before_query(SPIDER_CONN *conn, int *need_mon);
int spider_unlock_after_query(SPIDER_CONN *conn, int ret);
int spider_unlock_after_query_1(SPIDER_CONN *conn);
int spider_unlock_after_query_2(SPIDER_CONN *conn, ha_spider *spider, int link_idx, TABLE *table);
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -490,7 +490,6 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn(
DBUG_RETURN(conn);
error:
DBUG_ASSERT(!conn->mta_conn_mutex_file_pos.file_name);
error_too_many_ipport_count:
spider_conn_done(conn);
error_conn_init:
......
......@@ -1180,27 +1180,15 @@ static int spider_send_query(
}
} else
{
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
if ((error_num = dbton_hdl->set_sql_for_exec(
SPIDER_SQL_TYPE_SELECT_SQL, link_idx, link_idx_chain)))
DBUG_RETURN(error_num);
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_lock_before_query(conn, &spider->need_mons[link_idx]);
if ((error_num = spider_db_set_names(spider, conn,
link_idx)))
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);
pthread_mutex_unlock(&conn->mta_conn_mutex);
spider_unlock_after_query(conn, 0);
if (spider->need_mons[link_idx])
error_num = fields->ping_table_mon_from_table(link_idx_chain);
if ((error_num = spider->check_error_mode_eof(error_num)) ==
......@@ -1218,11 +1206,7 @@ static int spider_send_query(
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);
error_num= spider_unlock_after_query_1(conn);
if (spider->need_mons[link_idx])
error_num = fields->ping_table_mon_from_table(link_idx_chain);
if ((error_num = spider->check_error_mode_eof(error_num)) ==
......@@ -1234,13 +1218,9 @@ static int spider_send_query(
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))
{
if ((error_num = spider_db_store_result(spider, link_idx, table)))
if ((error_num = spider_unlock_after_query_2(conn, spider, link_idx, table)))
{
if (error_num != HA_ERR_END_OF_FILE && spider->need_mons[link_idx])
error_num = fields->ping_table_mon_from_table(link_idx_chain);
......@@ -1257,8 +1237,7 @@ static int spider_send_query(
} else
{
spider_db_discard_result(spider, link_idx, conn);
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
pthread_mutex_unlock(&conn->mta_conn_mutex);
spider_unlock_after_query(conn, 0);
}
}
}
......
......@@ -449,11 +449,6 @@ enum spider_malloc_id {
#define SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_TMP_ERROR_NUM \
if (thd && conn->error_mode) {SPIDER_RESTORE_DASTATUS; tmp_error_num = 0;}
#define SPIDER_SET_FILE_POS(A) \
{(A)->thd = current_thd; (A)->func_name = __func__; (A)->file_name = __FILE__; (A)->line_no = __LINE__;}
#define SPIDER_CLEAR_FILE_POS(A) \
{DBUG_PRINT("info", ("spider thd=%p func_name=%s file_name=%s line_no=%lu", (A)->thd, (A)->func_name ? (A)->func_name : "NULL", (A)->file_name ? (A)->file_name : "NULL", (A)->line_no)); (A)->thd = NULL; (A)->func_name = NULL; (A)->file_name = NULL; (A)->line_no = 0;}
class ha_spider;
typedef struct st_spider_share SPIDER_SHARE;
typedef struct st_spider_table_mon_list SPIDER_TABLE_MON_LIST;
......@@ -475,14 +470,6 @@ typedef struct st_spider_thread
volatile SPIDER_SHARE *queue_last;
} SPIDER_THREAD;
typedef struct st_spider_file_pos
{
THD *thd;
const char *func_name;
const char *file_name;
ulong line_no;
} SPIDER_FILE_POS;
typedef struct st_spider_link_for_hash
{
ha_spider *spider;
......@@ -612,7 +599,6 @@ typedef struct st_spider_conn
pthread_mutex_t mta_conn_mutex;
volatile bool mta_conn_mutex_lock_already;
volatile bool mta_conn_mutex_unlock_later;
SPIDER_FILE_POS mta_conn_mutex_file_pos;
uint join_trx;
int trx_isolation;
bool semi_trx_isolation_chk;
......
......@@ -5799,22 +5799,10 @@ 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;
spider_lock_before_query(conn, &mon_val);
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);
pthread_mutex_unlock(&conn->mta_conn_mutex);
spider_unlock_after_query(conn, 0);
spider_sys_index_end(table_tables);
spider_close_sys_table(thd, table_tables,
&open_tables_backup, TRUE);
......@@ -5823,12 +5811,7 @@ 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);
pthread_mutex_unlock(&conn->mta_conn_mutex);
spider_unlock_after_query(conn, 0);
if (lock && spider_param_use_snapshot_with_flush_tables(thd) == 2)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment