[Maria-developers] bzr commit into MariaDB 5.1, with Maria 1.5:maria branch (knielsen:2686)

2009-03-18 Thread knielsen
#At lp:maria

 2686 kniel...@knielsen-hq.org  2009-03-18
  Fix some Valgrind warnings.
modified:
  dbug/dbug.c
  mysql-test/valgrind.supp
  sql/mysqld.cc
  sql/scheduler.cc
  sql/sql_select.cc

=== modified file 'dbug/dbug.c'
--- a/dbug/dbug.c   2009-03-12 22:27:35 +
+++ b/dbug/dbug.c   2009-03-18 14:08:05 +
@@ -506,6 +506,7 @@ int DbugParse(CODE_STATE *cs, const char
   rel= control[0] == '+' || control[0] == '-';
   if ((!rel || (!stack-out_file  !stack-next)))
   {
+FreeState(cs, stack, 0);
 stack-flags= 0;
 stack-delay= 0;
 stack-maxdepth= 0;
@@ -1648,10 +1649,12 @@ static void FreeState(CODE_STATE *cs, st
 FreeList(state-processes);
   if (!is_shared(state, p_functions))
 FreeList(state-p_functions);
-  if (!is_shared(state, out_file))
+  if (!is_shared(state, out_file) 
+  state-out_file != stderr  state-out_file != stdout)
 DBUGCloseFile(cs, state-out_file);
   (void) fflush(cs-stack-out_file);
-  if (state-prof_file)
+  if (state-prof_file 
+  state-out_file != stderr  state-out_file != stdout)
 DBUGCloseFile(cs, state-prof_file);
   if (free_state)
 free((void*) state);

=== modified file 'mysql-test/valgrind.supp'
--- a/mysql-test/valgrind.supp  2008-11-21 14:21:50 +
+++ b/mysql-test/valgrind.supp  2009-03-18 14:08:05 +
@@ -229,6 +229,44 @@
 }
 
 {
+   libz deflate_slow 1
+   Memcheck:Cond
+   fun:deflate_slow
+   fun:deflate
+   fun:do_flush
+   fun:azflush
+}
+
+{
+   libz deflate_slow 2
+   Memcheck:Value8
+   fun:deflate_slow
+   fun:deflate
+   fun:do_flush
+   fun:azflush
+}
+
+{
+   libz deflate_slow 3
+   Memcheck:Cond
+   fun:deflate_slow
+   fun:deflate
+   fun:do_flush
+   fun:azclose
+}
+
+{
+   libz _tr_flush_block
+   Memcheck:Value8
+   fun:compress_block
+   fun:_tr_flush_block
+   fun:deflate_slow
+   fun:deflate
+   fun:do_flush
+   fun:azflush
+}
+
+{
libz deflate
Memcheck:Cond
obj:*/libz.so.*
@@ -256,6 +294,14 @@
fun:do_flush
 }
 
+{
+   libz deflate4
+   Memcheck:Cond
+   fun:deflate
+   fun:do_flush
+   fun:azclose
+}
+
 #
 # Warning from my_thread_init becasue mysqld dies before kill thread exists
 #
@@ -379,7 +425,7 @@
 }
 
 {
-   dlclose memory loss from plugin
+   dlclose memory loss from plugin variant 1
Memcheck:Leak
fun:calloc
fun:_dlerror_run
@@ -388,6 +434,19 @@
 }
 
 {
+   dlclose memory loss from plugin variant 2
+   Memcheck:Leak
+   fun:malloc
+   fun:_dl_close_worker
+   fun:_dl_close
+   fun:_dl_catch_error
+   fun:_dlerror_run
+   fun:dlclose
+   fun:_Z15free_plugin_memP12st_plugin_dl
+   fun:_Z13plugin_dl_delPK19st_mysql_lex_string
+}
+
+{
dlopen / ptread_cancel_init memory loss on Suse Linux 10.3 32/64 bit
Memcheck:Leak
fun:*alloc
@@ -588,3 +647,19 @@
fun:dlopen*
 }
 
+#
+# In glibc (checked version 2.7), inet_ntoa allocates an 18-byte
+# per-thread static buffer for the return value. That memory is freed
+# at thread exit, however if called from the main thread, Valgrind
+# does not see the free (test main.no-threads).
+#
+# Since inet_ntoa() does not allocate memory dynamically per-call, this
+# suppression is safe.
+#
+
+{
+   inet_ntoa thread local storage
+   Memcheck:Leak
+   fun:malloc
+   fun:inet_ntoa
+}

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc 2009-03-13 13:31:54 +
+++ b/sql/mysqld.cc 2009-03-18 14:08:05 +
@@ -4813,10 +4813,10 @@ static bool read_init_file(char *file_na
   DBUG_ENTER(read_init_file);
   DBUG_PRINT(enter,(name: %s,file_name));
   if (!(file=my_fopen(file_name,O_RDONLY,MYF(MY_WME
-return(1);
+DBUG_RETURN(1);
   bootstrap(file);
   (void) my_fclose(file,MYF(MY_WME));
-  return 0;
+  DBUG_RETURN(0);
 }
 
 
@@ -4837,6 +4837,7 @@ void handle_connection_in_main_thread(TH
   safe_mutex_assert_owner(LOCK_thread_count);
   thread_cache_size=0; // Safety
   threads.append(thd);
+  thd-connect_utime= thd-start_utime= my_micro_time();
   (void) pthread_mutex_unlock(LOCK_thread_count);
   handle_one_connection((void*) thd);
 }

=== modified file 'sql/scheduler.cc'
--- a/sql/scheduler.cc  2009-03-12 22:27:35 +
+++ b/sql/scheduler.cc  2009-03-18 14:08:05 +
@@ -470,6 +470,7 @@ static void libevent_add_connection(THD 
 DBUG_VOID_RETURN;
   }
   threads.append(thd);
+  thd-connect_utime= thd-start_utime= my_micro_time();
   libevent_thd_add(thd);
 
   pthread_mutex_unlock(LOCK_thread_count);

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc 2009-02-19 09:01:25 +
+++ b/sql/sql_select.cc 2009-03-18 14:08:05 +
@@ -1994,8 +1994,17 @@ JOIN::exec()
 tmp_fields_list2, tmp_all_fields2, 
 fields_list.elements, tmp_all_fields1))
  DBUG_VOID_RETURN;
-   curr_join-tmp_fields_list2= tmp_fields_list2;
-   curr_join-tmp_all_fields2= tmp_all_fields2;
+#ifdef HAVE_purify
+/*
+  Some GCCs use memcpy() for struct assignment, even for x=x.
+  GCC bug 

Re: [Maria-developers] bzr commit into MariaDB 5.1, with Maria 1.5:maria branch (monty:2680)

2009-03-18 Thread Michael Widenius

Hi!

 Sergei == Sergei Golubchik ser...@pisem.net writes:

Sergei Hi, Michael!
Sergei On Mar 12, Michael Widenius wrote:
 #At lp:maria based on 
 revid:mo...@askmonty.org-20090309141344-wriztb0fcn00syim
 
 2680 Michael Widenius2009-03-13
 Added pool-of-threads handling (with libevent)
 This is a backport of code from MySQL 6.0 with cleanups and extensions
 
 The following new options are supported
 configure options:
 --with-libevent ; Enable use of libevent, which is needed for pool of threads

Sergei Are you aware of the current scalability problems with the pool of
Sergei threads in 6.0 ? What are you going to do about it ?

No, haven't followed this discussion. Will look for it.

Either the people at Sun will come up with a solution or we have to
fix it ourselves.

Do you know where the bottleneck is?
Is it in libevent or scheduler.cc ?

Any ideas that you have of how to fix it?

A short term solution would be to add the getport code as an option to
scheduler.cc; That would fix the scalability problems at least on
Sun...

Regards,
Monty

___
Mailing list: https://launchpad.net/~maria-developers
Post to : maria-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~maria-developers
More help   : https://help.launchpad.net/ListHelp


Re: [Maria-developers] Working on microsecond patches

2009-03-18 Thread MARK CALLAGHAN
On Wed, Mar 18, 2009 at 7:23 AM, Michael Widenius mo...@askmonty.org wrote:

 Hi!

 Vadim == Vadim Tkachenko va...@percona.com writes:

 Vadim Michael,
 Vadim Thread-pool should be used very carefully.

 Vadim We tested it and InnoDB hangs in sysbench benchmarks when count of
 Vadim client connection  size of thread-pool.

 Yes, this a problem when you have more locks than threads.
 The innodb deadlock detector has to timeout the hanged items.

 Vadim The problem is transaction state. Some connections may do internals
 Vadim locks and after that could not enter to pool, because all slots are 
 busy.
 Vadim I expect you will have the same problem with Maria when it can fully
 Vadim support transactions.

 That is one of the main reasons I added --extra-port to MariaDB
 This allows you to connect and check/kill things if you get a hang.

 So things are not perfect now, but at least a little better.

I want a method in handler.h to timeout/wakeup threads blocked in a
handler method. Many engines have the notion of blocking on a lock for
a row/page (Innodb, Maria, maybe Falcon and PBXT). The scheduler
cannot do anything to get those threads back today. I run Innodb with
a 50 second lock wait timeout. That is a very long time to wait when
all threads get tied up. The scheduler may be able to do this with
THD::enter_cond for things blocked above a storage engine and that may
require killing the current statement for the thread to be waked.


 In the future we have to also look at creating more pool-threads when
 all pool-threads gets locked by a handler.

I don't trust this unless the server is able to create one thread per
connection and when running a server with 10,000+ connections I don't
think that will be a wise thing to do. I think this approach will lead
to rare but spectacular failures for hung servers.


 Regards,
 Monty

 ___
 Mailing list: https://launchpad.net/~maria-developers
 Post to     : maria-developers@lists.launchpad.net
 Unsubscribe : https://launchpad.net/~maria-developers
 More help   : https://help.launchpad.net/ListHelp




-- 
Mark Callaghan
mdcal...@gmail.com

___
Mailing list: https://launchpad.net/~maria-developers
Post to : maria-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~maria-developers
More help   : https://help.launchpad.net/ListHelp


[Maria-developers] bzr commit into MariaDB 5.1, with Maria 1.5:maria branch (knielsen:2685)

2009-03-18 Thread knielsen
#At lp:maria

 2685 kniel...@knielsen-hq.org  2009-03-18
  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.
  
  Also test connection limit on extra port with and without
  pool-of-threads enabled.
  
  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/connect.cnf
  mysql-test/t/pool_of_threads.cnf
modified:
  client/mysqltest.cc
  mysql-test/lib/My/ConfigFactory.pm
  mysql-test/r/connect.result
  mysql-test/r/pool_of_threads.result
  mysql-test/t/connect.test
  mysql-test/t/pool_of_threads.test

=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc   2009-02-19 09:01:25 +
+++ b/client/mysqltest.cc   2009-03-18 15:46:32 +
@@ -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.pm2009-02-15 10:58:34 +
+++ b/mysql-test/lib/My/ConfigFactory.pm2009-03-18 15:46:32 +
@@ -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/connect.result'
--- a/mysql-test/r/connect.result   2008-03-17 11:26:00 +
+++ b/mysql-test/r/connect.result   2009-03-18 15:46:32 +
@@ -215,6 +215,13 @@ SET GLOBAL event_scheduler = OFF;
 
 # -- End of Bug#35074.
 
+SELECT 'Connection on extra port ok';
+Connection on extra port ok
+Connection on extra port ok
+SELECT 'Connection on extra port 2 ok';
+Connection on extra port 2 ok
+Connection on extra port 2 ok
+# -- Success: more than --extra-max-connections + 1 normal connections not 
possible
 # --
 # -- End of 5.1 tests
 # --

=== modified file 'mysql-test/r/pool_of_threads.result'
--- a/mysql-test/r/pool_of_threads.result   2009-03-12 22:27:35 +
+++ b/mysql-test/r/pool_of_threads.result   2009-03-18 15:46:32 +
@@ -2151,3 +2151,23 @@ Privat (Private Nutzung) Mobilfunk
 Warnings:
 Warning1052Column 'kundentyp' in group statement is ambiguous
 drop table t1;
+SELECT sleep(5);
+SELECT sleep(5);
+# -- 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
+SELECT 'Connection on extra port 2 ok';
+Connection on extra port 2 ok
+Connection on extra port 2 ok
+# -- Success: more than --extra-max-connections + 1 normal connections not 
possible
+sleep(5)
+0
+sleep(5)
+0

=== added 

Re: [Maria-developers] bzr commit into MariaDB 5.1, with Maria 1.5:maria branch (knielsen:2686)

2009-03-18 Thread Kristian Nielsen
Sergei Golubchik ser...@pisem.net writes:

 === modified file 'dbug/dbug.c'
 --- a/dbug/dbug.c2009-03-12 22:27:35 +
 +++ b/dbug/dbug.c2009-03-18 14:08:05 +
 @@ -506,6 +506,7 @@ int DbugParse(CODE_STATE *cs, const char
rel= control[0] == '+' || control[0] == '-';
if ((!rel || (!stack-out_file  !stack-next)))
{
 +FreeState(cs, stack, 0);

 you may be freeing uuninitialized data here.

Ok, that's not good, obviously.

 What are you trying to fix anyway ?

The leak from this Valgrind warning:

==28234== 51 bytes in 1 blocks are definitely lost in loss record 3 of 7
==28234==at 0x4C22FAB: malloc (vg_replace_malloc.c:207)
==28234==by 0xAA3452: DbugMalloc (dbug.c:2164)
==28234==by 0xAA2864: ListAddDel (dbug.c:1489)
==28234==by 0xAA009E: DbugParse (dbug.c:572)
==28234==by 0xAA0A27: _db_set_init_ (dbug.c:913)
==28234==by 0x66C4C3: mysqld_get_one_option (mysqld.cc:7942)
==28234==by 0xA89E5C: handle_options (my_getopt.c:530)
==28234==by 0x6720C4: get_options(int*, char**) (mysqld.cc:8524)
==28234==by 0x672590: init_common_variables(char const*, int, char**, char 
const**) (mysqld.cc:3312)
==28234==by 0x673EAB: main (mysqld.cc:4318)

If I remember correctly, it is init_settings.keywords that is not de-allocated
correctly when DbugParse is called multiple times.

Due to BUG#43418, mysql-test-run was not detecting all Valgrind warnings. And
after I fixed that bug, a number of additional warnings surfaced, this on
included.

If you have a better suggestion for silencing this leak, that would be
great. Otherwise I need to look a bit deeper, I admit I did not properly check
for the possibility of freeing uninitialised pointers.

 @@ -1648,10 +1649,12 @@ static void FreeState(CODE_STATE *cs, st
  FreeList(state-processes);
if (!is_shared(state, p_functions))
  FreeList(state-p_functions);
 -  if (!is_shared(state, out_file))
 +  if (!is_shared(state, out_file) 
 +  state-out_file != stderr  state-out_file != stdout)
  DBUGCloseFile(cs, state-out_file);
(void) fflush(cs-stack-out_file);
 -  if (state-prof_file)
 +  if (state-prof_file 
 +  state-out_file != stderr  state-out_file != stdout)

 typo. you obviously want s/out_file/prof_file/g

Well spotted!

Thanks a lot, Sergei!

 - Kristian.

___
Mailing list: https://launchpad.net/~maria-developers
Post to : maria-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~maria-developers
More help   : https://help.launchpad.net/ListHelp