Bug #45951 Reports "Error in my_thread_global_end(): 55 threads didn't exit" in threaded ap
Submitted: 5 Jul 2009 9:08 Modified: 5 Aug 2009 7:51
Reporter: Pieter De Wit Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: C API (client library) Severity:S3 (Non-critical)
Version:5.1.31-1ubuntu2 OS:Linux (Ubuntu 9.04)
Assigned to: CPU Architecture:Any
Tags: linux client, my_thread_global_end

[5 Jul 2009 9:08] Pieter De Wit
Description:
Hi Guys,

I have an error close to http://bugs.php.net/bug.php?id=41350

The changes are that this is on a C app, compiled against the mysql version as above. The application is really a sendmail milter. I have checked my code over and over and I can't spot if I am doing something wrong or if this is just the error as above.

This is the code I close on the last events:

        if (priv->mysql_init!=0)
        {
                logger ("%s","[CLEANUP] Closing MySQL");
                mysql_close (&priv->mysql);
                mysql_library_end ();
                priv->mysql_init=0;
        }

I have quite a few of those all over to make 100% I close the libs - here is the compile command-line:

gcc -ggdb -Wall -Werror -D_REENTRANT -g -O2  -L/usr/lib/libmilter  -o pgmf main.o logix_sockets.o  -lmysqlclient_r -lmilter -lpthread

If I comment out the sql code all is well. I have also found this error on a gentoo box running mysql 5.0.70

Thanks !

How to repeat:
Create a "hello world" sendmail milter.
Add some sql queries
wait a while :)

Suggested fix:
mysql_library_end should kill all the threads/memory/etc for that thread ?
[6 Jul 2009 5:12] Sveta Smirnova
Thank you for the report.

Please provide example program demonstrating the problem.
[6 Jul 2009 6:25] Pieter De Wit
Hi,

I don't mind sending someone the code, but I would prefer not to put it up for public domain. I can create a copy of it and publish that for you guys but that will take me a day or two?

Thanks,

Pieter
[6 Jul 2009 6:41] Sveta Smirnova
Thank you for the feedback.

Yes, you could privately upload it. See description how to do it in "Files" section. Thanks in advance.
[6 Jul 2009 6:51] Pieter De Wit
All uploaded - let me know if you have issues compiling etc.

Thanks,

Pieter
[20 Jul 2009 10:31] Pieter De Wit
Hi Guys,

Seems the app crashing bit was "solved" or at least, gone away. I am not sure what happened. Anyways, it is still showing the message in the log:

Error in my_thread_global_end(): 1267 threads didn't exit

Thanks,

Pieter
[3 Aug 2009 8:19] Susanne Ebrecht
Do you still get a core dump or something like this?
[3 Aug 2009 8:24] Pieter De Wit
Hi,

I can't ever recall getting a core dump - just a seg. fault :)

Cheers,

Pieter
[3 Aug 2009 9:00] Susanne Ebrecht
I wanted to know if server still is crashing or if we are allowed to close this bug report.
[3 Aug 2009 17:37] Pieter De Wit
Hi,

Sorry - yes - the application still crashes, the mysql server carries on running.

Thanks,

Pieter
[5 Aug 2009 7:51] Sveta Smirnova
Thank you for the feedback.

Backtrace you provided does not contain calls to MySQL C API, so it is most likely not MySQL bug and I close the report as such. If you are able to prove it is problem with MySQL C API itself feel free to reopen the report.

Regarding to code provided be sure you have corresponding count of mysql_library_end and mysql_library_init/mysql_init.