mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bug #51135 Please increase the maximum number of connections allowed in mysqltest
Added --max-connections= argument to mysqltest and mtr Small fix to first patch: forgot to check before free'ing connections array
This commit is contained in:
@ -67,6 +67,7 @@
|
|||||||
#define MAX_COLUMNS 256
|
#define MAX_COLUMNS 256
|
||||||
#define MAX_EMBEDDED_SERVER_ARGS 64
|
#define MAX_EMBEDDED_SERVER_ARGS 64
|
||||||
#define MAX_DELIMITER_LENGTH 16
|
#define MAX_DELIMITER_LENGTH 16
|
||||||
|
#define DEFAULT_MAX_CONN 128
|
||||||
|
|
||||||
/* Flags controlling send and reap */
|
/* Flags controlling send and reap */
|
||||||
#define QUERY_SEND_FLAG 1
|
#define QUERY_SEND_FLAG 1
|
||||||
@ -75,7 +76,8 @@
|
|||||||
enum {
|
enum {
|
||||||
OPT_SKIP_SAFEMALLOC=OPT_MAX_CLIENT_OPTION,
|
OPT_SKIP_SAFEMALLOC=OPT_MAX_CLIENT_OPTION,
|
||||||
OPT_PS_PROTOCOL, OPT_SP_PROTOCOL, OPT_CURSOR_PROTOCOL, OPT_VIEW_PROTOCOL,
|
OPT_PS_PROTOCOL, OPT_SP_PROTOCOL, OPT_CURSOR_PROTOCOL, OPT_VIEW_PROTOCOL,
|
||||||
OPT_MAX_CONNECT_RETRIES, OPT_MARK_PROGRESS, OPT_LOG_DIR, OPT_TAIL_LINES
|
OPT_MAX_CONNECT_RETRIES, OPT_MAX_CONNECTIONS,
|
||||||
|
OPT_MARK_PROGRESS, OPT_LOG_DIR, OPT_TAIL_LINES
|
||||||
};
|
};
|
||||||
|
|
||||||
static int record= 0, opt_sleep= -1;
|
static int record= 0, opt_sleep= -1;
|
||||||
@ -88,6 +90,7 @@ const char *opt_logdir= "";
|
|||||||
const char *opt_include= 0, *opt_charsets_dir;
|
const char *opt_include= 0, *opt_charsets_dir;
|
||||||
static int opt_port= 0;
|
static int opt_port= 0;
|
||||||
static int opt_max_connect_retries;
|
static int opt_max_connect_retries;
|
||||||
|
static int opt_max_connections= DEFAULT_MAX_CONN;
|
||||||
static my_bool opt_compress= 0, silent= 0, verbose= 0;
|
static my_bool opt_compress= 0, silent= 0, verbose= 0;
|
||||||
static my_bool debug_info_flag= 0, debug_check_flag= 0;
|
static my_bool debug_info_flag= 0, debug_check_flag= 0;
|
||||||
static my_bool tty_password= 0;
|
static my_bool tty_password= 0;
|
||||||
@ -240,7 +243,8 @@ struct st_connection
|
|||||||
int query_done;
|
int query_done;
|
||||||
#endif /*EMBEDDED_LIBRARY*/
|
#endif /*EMBEDDED_LIBRARY*/
|
||||||
};
|
};
|
||||||
struct st_connection connections[128];
|
|
||||||
|
struct st_connection *connections= NULL;
|
||||||
struct st_connection* cur_con= NULL, *next_con, *connections_end;
|
struct st_connection* cur_con= NULL, *next_con, *connections_end;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1105,6 +1109,7 @@ void close_connections()
|
|||||||
mysql_close(next_con->util_mysql);
|
mysql_close(next_con->util_mysql);
|
||||||
my_free(next_con->name, MYF(MY_ALLOW_ZERO_PTR));
|
my_free(next_con->name, MYF(MY_ALLOW_ZERO_PTR));
|
||||||
}
|
}
|
||||||
|
my_free(connections, MYF(MY_WME));
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1145,7 +1150,8 @@ void free_used_memory()
|
|||||||
uint i;
|
uint i;
|
||||||
DBUG_ENTER("free_used_memory");
|
DBUG_ENTER("free_used_memory");
|
||||||
|
|
||||||
close_connections();
|
if (connections)
|
||||||
|
close_connections();
|
||||||
close_files();
|
close_files();
|
||||||
hash_free(&var_hash);
|
hash_free(&var_hash);
|
||||||
|
|
||||||
@ -5121,7 +5127,7 @@ void do_connect(struct st_command *command)
|
|||||||
{
|
{
|
||||||
if (!(con_slot= find_connection_by_name("-closed_connection-")))
|
if (!(con_slot= find_connection_by_name("-closed_connection-")))
|
||||||
die("Connection limit exhausted, you can have max %d connections",
|
die("Connection limit exhausted, you can have max %d connections",
|
||||||
(int) (sizeof(connections)/sizeof(struct st_connection)));
|
opt_max_connections);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef EMBEDDED_LIBRARY
|
#ifdef EMBEDDED_LIBRARY
|
||||||
@ -5870,6 +5876,10 @@ static struct my_option my_long_options[] =
|
|||||||
"Max number of connection attempts when connecting to server",
|
"Max number of connection attempts when connecting to server",
|
||||||
(uchar**) &opt_max_connect_retries, (uchar**) &opt_max_connect_retries, 0,
|
(uchar**) &opt_max_connect_retries, (uchar**) &opt_max_connect_retries, 0,
|
||||||
GET_INT, REQUIRED_ARG, 500, 1, 10000, 0, 0, 0},
|
GET_INT, REQUIRED_ARG, 500, 1, 10000, 0, 0, 0},
|
||||||
|
{"max-connections", OPT_MAX_CONNECTIONS,
|
||||||
|
"Max number of open connections to server",
|
||||||
|
(uchar**) &opt_max_connections, (uchar**) &opt_max_connections, 0,
|
||||||
|
GET_INT, REQUIRED_ARG, 128, 8, 5120, 0, 0, 0},
|
||||||
{"password", 'p', "Password to use when connecting to server.",
|
{"password", 'p', "Password to use when connecting to server.",
|
||||||
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
|
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
|
||||||
{"port", 'P', "Port number to use for connection or 0 for default to, in "
|
{"port", 'P', "Port number to use for connection or 0 for default to, in "
|
||||||
@ -7741,12 +7751,6 @@ int main(int argc, char **argv)
|
|||||||
/* Init expected errors */
|
/* Init expected errors */
|
||||||
memset(&saved_expected_errors, 0, sizeof(saved_expected_errors));
|
memset(&saved_expected_errors, 0, sizeof(saved_expected_errors));
|
||||||
|
|
||||||
/* Init connections */
|
|
||||||
memset(connections, 0, sizeof(connections));
|
|
||||||
connections_end= connections +
|
|
||||||
(sizeof(connections)/sizeof(struct st_connection)) - 1;
|
|
||||||
next_con= connections + 1;
|
|
||||||
|
|
||||||
#ifdef EMBEDDED_LIBRARY
|
#ifdef EMBEDDED_LIBRARY
|
||||||
/* set appropriate stack for the 'query' threads */
|
/* set appropriate stack for the 'query' threads */
|
||||||
(void) pthread_attr_init(&cn_thd_attrib);
|
(void) pthread_attr_init(&cn_thd_attrib);
|
||||||
@ -7808,6 +7812,13 @@ int main(int argc, char **argv)
|
|||||||
verbose_msg("Tracing progress in '%s'.", progress_file.file_name());
|
verbose_msg("Tracing progress in '%s'.", progress_file.file_name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Init connections, allocate 1 extra as buffer + 1 for default */
|
||||||
|
connections= (struct st_connection*)
|
||||||
|
my_malloc((opt_max_connections+2) * sizeof(struct st_connection),
|
||||||
|
MYF(MY_WME | MY_ZEROFILL));
|
||||||
|
connections_end= connections + opt_max_connections +1;
|
||||||
|
next_con= connections + 1;
|
||||||
|
|
||||||
var_set_int("$PS_PROTOCOL", ps_protocol);
|
var_set_int("$PS_PROTOCOL", ps_protocol);
|
||||||
var_set_int("$SP_PROTOCOL", sp_protocol);
|
var_set_int("$SP_PROTOCOL", sp_protocol);
|
||||||
var_set_int("$VIEW_PROTOCOL", view_protocol);
|
var_set_int("$VIEW_PROTOCOL", view_protocol);
|
||||||
|
@ -203,6 +203,7 @@ my $opt_skip_core;
|
|||||||
|
|
||||||
our $opt_check_testcases= 1;
|
our $opt_check_testcases= 1;
|
||||||
my $opt_mark_progress;
|
my $opt_mark_progress;
|
||||||
|
my $opt_max_connections;
|
||||||
|
|
||||||
my $opt_sleep;
|
my $opt_sleep;
|
||||||
|
|
||||||
@ -923,6 +924,7 @@ sub command_line_setup {
|
|||||||
'warnings!' => \$opt_warnings,
|
'warnings!' => \$opt_warnings,
|
||||||
'timestamp' => \&report_option,
|
'timestamp' => \&report_option,
|
||||||
'timediff' => \&report_option,
|
'timediff' => \&report_option,
|
||||||
|
'max-connections=i' => \$opt_max_connections,
|
||||||
|
|
||||||
'help|h' => \$opt_usage,
|
'help|h' => \$opt_usage,
|
||||||
'list-options' => \$opt_list_options,
|
'list-options' => \$opt_list_options,
|
||||||
@ -4909,6 +4911,10 @@ sub start_mysqltest ($) {
|
|||||||
mtr_add_arg($args, "--ssl");
|
mtr_add_arg($args, "--ssl");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( $opt_max_connections ) {
|
||||||
|
mtr_add_arg($args, "--max-connections=%d", $opt_max_connections);
|
||||||
|
}
|
||||||
|
|
||||||
if ( $opt_embedded_server )
|
if ( $opt_embedded_server )
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -5467,6 +5473,7 @@ Misc options
|
|||||||
timestamp Print timestamp before each test report line
|
timestamp Print timestamp before each test report line
|
||||||
timediff With --timestamp, also print time passed since
|
timediff With --timestamp, also print time passed since
|
||||||
*previous* test started
|
*previous* test started
|
||||||
|
max-connections=N Max number of open connection to server in mysqltest
|
||||||
|
|
||||||
HERE
|
HERE
|
||||||
exit(1);
|
exit(1);
|
||||||
|
Reference in New Issue
Block a user