Michael Bacarella wrote:
We recently started getting "Can't create thread" errors since
switching to Debian.

On Red Hat 8.0 we were able to spawn more than 400 mysql threads
and never encountered this error.  mysql 3.23.56 compiled from
source, stock kernel.  (2GB of RAM)

Now we get it all the time on Debian and the MySQL AB 3.23.58
binary around 245 threads, linux 2.4.23 custom kernel.  (3GB of RAM,
not that it matters)

Are we missing a setting?

Does Red Hat have some kind of userland address space hack that
we're not aware of?

Do you have any special kernel config options that you did not use before?


Actually, we just found something interesting on the Debian box.

# ps aux | grep mysqld
[...]
mysql    25303  0.4 30.4 1228720 947112 ?    S    16:16   0:23 
/usr/local/mysql/bin/mysqld --defaults-extra-file=/usr/local/mysql/data/my.cnf 
--basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data --user=mysql 
--pid-file=/usr/local/mysql/data/dbms3.pid --skip-locking
[...]

# tail /proc/25303/maps
bee01000-bf000000 rwxp 00001000 00:00 0 bf000000-bf001000 ---p 00000000 00:00 0 bf001000-bf200000 rwxp 00001000 00:00 0 bf200000-bf201000 ---p 00000000 00:00 0 bf201000-bf400000 rwxp 00001000 00:00 0 bf400000-bf401000 ---p 00000000 00:00 0 bf401000-bf600000 rwxp 00001000 00:00 0 bf600000-bf601000 ---p 00000000 00:00 0 bf601000-bf800000 rwxp 00001000 00:00 0 bfffa000-c0000000 rwxp ffffb000 00:00 0


the thread stacks are 2MB apiece (bf601000-bf800000 is
2093056 bytes, or 2044kB)!  Yet:

# mysql -e 'show variables' | grep thread_stack
thread_stack    196608

It seems like the setting does nothing for us.  We top out at
exactly 256 threads.


Ok, that's the problem. Thread stack on older glibc versions is hard-coded. Newer versions (at least 2.3.2) will have a truly adjustable stack size if it is compiled with FLOATING_STACKS defined, which is off by default. One possibility is that the MySQL build team moved to linking against glibc 2.3.2, but did not enable floating stacks in it. Maybe Lenz can comment on it.



There are a couple of possiblities for the fix. I believe at some point in 2.3 glibc started having true user-adjustable thread stack sizes. Try compiling MySQL on your Debian box and check the stack size you are getting - maybe by some odd luck the Debian team enabled floating stacks. But even if they did, you are still limited to 1021 threads with this option.


If that does not work, my next line of defense would be to clone the bk repository, and follow the instructions in Docs/linuxthreads.txt - this would give you a good old link against a patched glibc 2.2.5 which to my knowledge is problem free, and the binary you get is 100% system glibc independent (a regular statically linked binary still depends on local shared libraries for DNS and user lookups). Another possiblity, if you do not mind messing with the main glibc on the box, is to recomile it fixing up PTHREAD_THREAD_MAX and defining FLOATING_STACKS

--
Sasha Pachev
Create online surveys at http://www.surveyz.com/

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to