#158643 stack_size for mysql-server

#158643#5
Date:
2002-08-28 17:21:46 UTC
From:
To:
MySQL AB links the mysql server statically against libpthread.a, the
latter compiled with STACK_SIZE of 256KB.

mysql-server is today dynamically linked with the default libpthread.so,
and the STACK_SIZE here is 2MB. On a big, busy server - the package is
useless - with ~700 connections and 600MB of buffer space libc will start
to write random data on the stack - which is fatal.

This should maybe be commented on in the configuration file.

Details: http://www.mysql.com/doc/en/Linux.html

#158643#10
Date:
2003-12-07 19:50:17 UTC
From:
To:
The mysqld server fails to work on ia64 Linux apparently due to the
recent switch to a TLS-enabled glibc.  The problem is that the
interrupt thread fails to get created (it fails with EINVAL).  The
workaround that the patch below uses is to not try to limit the
stack-size to 32KB.  The code seems to be buggy to begin with (it
should at least use a stack-size of MAX(32768, PTHREAD_STACK_MIN); on
ia64, PTHREAD_STACK_MIN is 196608 bytes), but I think the reason this
bug got triggered now is due to the fact that NPTL insists that the
stack size no less than:

  guardsize + static-TLS-size + MINIMAL_REST_STACK + pagesize

where

  guardsize		>= 1 page (16KB with the Debian kernel)
  MINIMAL_REST_STACK:	16KB on ia64
  page_size:		16KB with the Debian kernel

In other words, the stack would have bo be at least 48KB for the
thread-creation to succeed.  Of course, with a page size of 64KB, this
minimum would increase to 144KB.

The static-TLS-size is somewhat unpredictable, since that's something
that will change whenever one of the dependent shared libraries
chooses to use more or less thread-local storage.  At the moment, only
glibc seems to use TLS and it's only about 16 bytes, but that can
obviously change easily.

In summary, I'd recommend that mysqld should at the very least
increase the stack-size to MAX(32768, PTHREAD_STACK_MIN).  However,
since virtual memory is cheap on 64-bit architectures, it might be
best not to try to set the stack size at all on those architectures.
--- sql/mysqld.cc~	2003-12-07 10:09:21.000000000 -0800
+++ sql/mysqld.cc	2003-12-07 10:32:29.291545673 -0800
@@ -1700,7 +1700,7 @@
 #endif

   (void) pthread_mutex_lock(&LOCK_thread_count);
-  if ((error=pthread_create(&signal_thread,&thr_attr,signal_hand,0)))
+  if ((error=pthread_create(&signal_thread,NULL/*&thr_attr*/,signal_hand,0)))
   {
     sql_print_error("Can't create interrupt-thread (error %d, errno: %d)",
 		    error,errno);

#158643#17
Date:
2011-01-16 15:22:51 UTC
From:
To:
Hi,

Is this still an issue in Debian Squeeze?