← Back to team overview

maria-developers team mailing list archive

bzr commit into MariaDB 5.1, with Maria 1.5:maria branch (knielsen:2682)

 

#At lp:maria

 2682 knielsen@xxxxxxxxxxxxxxx	2009-03-13
      Add testing of extra port for pool-of-threads.
      
      The additional test uses up all threads in the pool with SELECT
      SLEEP(), and tests that this makes normal connections block, but
      connections on the extra port still work.
      
      Add --connect-timeout option to mysqltest program.
      
      Add facility for --extra-port option to ConfigFactory.
      
      Fix regexp typo in ConfigFactory.pm
removed:
  mysql-test/t/pool_of_threads-master.opt
added:
  mysql-test/t/pool_of_threads.cnf
modified:
  client/mysqltest.cc
  mysql-test/lib/My/ConfigFactory.pm
  mysql-test/r/pool_of_threads.result
  mysql-test/t/pool_of_threads.test

=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc	2009-02-19 09:01:25 +0000
+++ b/client/mysqltest.cc	2009-03-13 15:13:29 +0000
@@ -76,7 +76,7 @@ enum {
   OPT_SKIP_SAFEMALLOC=OPT_MAX_CLIENT_OPTION,
   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_GLOBAL_SUBST
+  OPT_GLOBAL_SUBST, OPT_MY_CONNECT_TIMEOUT
 };
 
 static int record= 0, opt_sleep= -1;
@@ -87,6 +87,7 @@ const char *opt_include= 0, *opt_charset
 static int opt_port= 0;
 static int opt_max_connect_retries;
 static my_bool opt_compress= 0, silent= 0, verbose= 0;
+static int opt_connect_timeout= -1;
 static my_bool debug_info_flag= 0, debug_check_flag= 0;
 static my_bool tty_password= 0;
 static my_bool opt_mark_progress= 0;
@@ -4952,6 +4953,9 @@ void do_connect(struct st_command *comma
   if (opt_charsets_dir)
     mysql_options(&con_slot->mysql, MYSQL_SET_CHARSET_DIR,
                   opt_charsets_dir);
+  if (opt_connect_timeout >= 0)
+    mysql_options(&con_slot->mysql, MYSQL_OPT_CONNECT_TIMEOUT,
+                  &opt_connect_timeout);
 
 #ifdef HAVE_OPENSSL
   if (opt_use_ssl || con_ssl)
@@ -5692,6 +5696,9 @@ static struct my_option my_long_options[
 #include "sslopt-longopts.h"
   {"test-file", 'x', "Read test from/in this file (default stdin).",
    0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+  {"connect-timeout", OPT_MY_CONNECT_TIMEOUT, "Client connection timeout",
+   (uchar**) &opt_connect_timeout, (uchar**) &opt_connect_timeout, 0,
+   GET_INT, REQUIRED_ARG, -1, -1, 0, 0, 0, 0},
   {"timer-file", 'm', "File where the timing in micro seconds is stored.",
    0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"tmpdir", 't', "Temporary directory where sockets are put.",

=== modified file 'mysql-test/lib/My/ConfigFactory.pm'
--- a/mysql-test/lib/My/ConfigFactory.pm	2009-02-15 10:58:34 +0000
+++ b/mysql-test/lib/My/ConfigFactory.pm	2009-03-13 15:13:29 +0000
@@ -202,6 +202,7 @@ my @mysqld_rules=
  { 'pid-file' => \&fix_pidfile },
  { '#host' => \&fix_host },
  { 'port' => \&fix_port },
+ { '#extra-port' => \&fix_port },
  { 'socket' => \&fix_socket },
  { 'log-error' => \&fix_log_error },
  { 'general-log' => sub { return 1; } },
@@ -353,7 +354,7 @@ sub post_check_client_group {
 sub post_check_client_groups {
  my ($self, $config)= @_;
 
- my $first_mysqld= $config->first_like('mysqld.');
+ my $first_mysqld= $config->first_like('mysqld\.');
 
  return unless $first_mysqld;
 

=== modified file 'mysql-test/r/pool_of_threads.result'
--- a/mysql-test/r/pool_of_threads.result	2009-03-12 22:27:35 +0000
+++ b/mysql-test/r/pool_of_threads.result	2009-03-13 15:13:29 +0000
@@ -2151,3 +2151,20 @@ Privat (Private Nutzung)	Mobilfunk
 Warnings:
 Warning	1052	Column 'kundentyp' in group statement is ambiguous
 drop table t1;
+SELECT sleep(5);
+SELECT sleep(5);
+connect(localhost,root,,test,12500,/home/knielsen/devel/maria/my/work-1.5/mysql-test/var/tmp/mysqld.1.sock);
+# -- Success: more than --thread-pool-size normal connections not possible
+sleep(5)
+0
+sleep(5)
+0
+SELECT sleep(5);
+SELECT sleep(5);
+SELECT 'Connection on extra port ok';
+Connection on extra port ok
+Connection on extra port ok
+sleep(5)
+0
+sleep(5)
+0

=== removed file 'mysql-test/t/pool_of_threads-master.opt'
--- a/mysql-test/t/pool_of_threads-master.opt	2009-03-12 22:27:35 +0000
+++ b/mysql-test/t/pool_of_threads-master.opt	1970-01-01 00:00:00 +0000
@@ -1 +0,0 @@
---test-ignore-wrong-options --thread-handling=pool-of-threads

=== added file 'mysql-test/t/pool_of_threads.cnf'
--- a/mysql-test/t/pool_of_threads.cnf	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/pool_of_threads.cnf	2009-03-13 15:13:29 +0000
@@ -0,0 +1,13 @@
+!include include/default_my.cnf
+
+[mysqld.1]
+test-ignore-wrong-options
+thread-handling=   pool-of-threads
+thread_pool_size=  2
+extra-port=        @mysqld.1.#extra-port
+
+[client]
+connect-timeout=   2
+
+[ENV]
+MASTER_EXTRA_PORT= @mysqld.1.extra-port

=== modified file 'mysql-test/t/pool_of_threads.test'
--- a/mysql-test/t/pool_of_threads.test	2009-03-12 22:27:35 +0000
+++ b/mysql-test/t/pool_of_threads.test	2009-03-13 15:13:29 +0000
@@ -5,3 +5,55 @@
 
 -- source include/common-tests.inc
 
+
+# Test that we cannot have more simultaneous connections than
+# --thread-pool-size on the standard port, but _can_ have additional
+# connections on the extra port.
+
+# First set two connections running, and check that extra connection
+# on normal port fails due to--thread-pool-size=2
+connection default;
+send SELECT sleep(5);
+
+connect(con2,localhost,root,,);
+connection con2;
+send SELECT sleep(5);
+--sleep 1
+
+--disable_abort_on_error
+--disable_result_log
+connect(con3,localhost,root,,);
+--enable_result_log
+--enable_abort_on_error
+let $error = $mysql_errno;
+if (!$error)
+{
+  --echo # -- Error: managed to establish more than --thread-pool-size connections
+}
+if ($error)
+{
+  --echo # -- Success: more than --thread-pool-size normal connections not possible
+}
+
+connection default;
+--reap
+connection con2;
+--reap
+
+# Now try again, but this time use the extra port to successfully connect.
+
+connection default;
+send SELECT sleep(5);
+
+connection con2;
+send SELECT sleep(5);
+--sleep 1
+
+connect(extracon,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,);
+connection extracon;
+SELECT 'Connection on extra port ok';
+
+connection default;
+--reap
+connection con2;
+--reap