Bug #31687 Error in my_thread_global_end(): 1 threads didn't exit
Submitted: 18 Oct 2007 8:35 Modified: 3 Jan 2008 9:04
Reporter: ming lu Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: Installing Severity:S2 (Serious)
Version:5.1.22 OS:Microsoft Windows
Assigned to: CPU Architecture:Any
Triage: D3 (Medium)

[18 Oct 2007 8:35] ming lu
I compile the mysql odbc 3.51.21 by myself, the mysql server i used is server 5.1.21. Then i run the tests against the myodbc(use the testcases in mysql-connector-odbc-3.51.21\test\ ). 

The test result like this: 

D:\mysql-connector-odbc-3.51.21\test\release>my_bulk.exe mysql root 111111
# Total rows fetched: 1600
ok 1 - t_bulk_insert
# Total rows fetched: 3
ok 2 - t_mul_pkdel
ok 3 - t_bulk_insert_indicator
ok 4 - t_bulk_insert_rows
Error in my_thread_global_end(): 1 threads didn't exit

I known that these is a server's bug(bug#25621) related with this error, but it had been fixed in this version, hadn't it?  Why does the error recur? 

How to repeat:
compile the myodbc 3.51.21 with mysql server 5.1.21, then run the regressive testsuite.
[18 Oct 2007 12:04] Susanne Ebrecht
Hello Ming Lu,

thanks for writing a bug report.

Unfortunately, I can't reproduce this problem. The test works fine here.

How did you compile the driver?

Please, try also MyODBC version 5.1.

[19 Oct 2007 1:40] ming lu
My compile environment:
      Windows 2000 Advanced Server (SP4)
      VS .net 2003
      qt 3.3.2
      cmake 2.4
      bison 2.1
      MySQL Server 5.1.21

Btw, I find the same error when starting the mysql server 5.1.22 by command-line mode. The test like this:

C:\Program Files\MySQL\MySQL Server 5.1\bin>mysqld.exe --defaults-file="c:\program files\mysql\mysql server 5.1\my.ini" --console
071019  9:35:32  InnoDB: Started; log sequence number 0 7040721
071019  9:35:32 [ERROR] Can't open and lock privilege tables: Table 'mysql.serve
rs' doesn't exist
071019  9:35:32 [Note] Event Scheduler: Loaded 0 events
071019  9:35:32 [Note] mysqld.exe: ready for connections.
Version: '5.1.22-rc-community'  socket: ''  port: 3306  MySQL Community Server (GPL)
071019  9:36:02 [ERROR] mysqld.exe: Got signal 2. Aborting!

071019  9:36:02 [Note] Event Scheduler: Purging the queue. 0 events
071019  9:36:02  InnoDB: Starting shutdown...
071019  9:36:03  InnoDB: Shutdown completed; log sequence number 0 7040721
071019  9:36:03 [Note] mysqld.exe: Shutdown complete

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

When the server started, i didn't do any operation against the server, then i shutdown the server by 'crtl+c' in command-line mode.
[19 Oct 2007 11:02] Susanne Ebrecht
Hi Ming Lu,

thanks for your details. I can reproduce this.


[30 Oct 2007 21:27] Hafiz Abdur Rahman
I am also getting this error message (my_thread_global_end()). My server version is 5.0.27-community-nt, odbc driver is 3.51.21-win32.msi. My development tools are MS visual Studio 2003 (unmanaged C++) in Windows XP. I am using Boost C++ libraries 1.33.1 (threads and other libraries) with Microsoft OLE DB driver for ODBC to connect MySQL database. My program used to work fine before installing this new version of ODBC driver. I will appreciate any update about this bug report.

Hafiz Abdur Rahman
UBC, Vancouver, Canada.
[31 Oct 2007 2:42] Tom Donovan
Compiling Connector/ODBC 3.51.21r807 from source and linking with libraries from MySQL 5.0.48 corrects the problem. 

Only the driver (myodbc3.dll) needs to be replaced, so TrollTech Qt isn't needed to do this. I used Visual Studio 2005 SP1.

Apparently MySQL versions 5.0.44 and later are fixed. Unfortunately the Windows downloads for Connector/ODBC versions 3.51.16 through 3.51.21 appear to be linked with a version of MySQL which was not fixed - so they still show the 'threads didn't exit' message.
[31 Oct 2007 19:34] Jian Xu
Re-build odbc driver on windows for MySQL server v 5.0.45 not successful.
I cannot find a win32 binary version of v5.0.48 (only for Enterprise version, please advise)  Thanks all.

Link error : 
1>mysqlclient.lib(my_compress.obj) : error LNK2019: unresolved external symbol _compress referenced in function _my_compress_alloc
1>mysqlclient.lib(my_compress.obj) : error LNK2019: unresolved external symbol _uncompress referenced in function _my_uncompress
1>C:\download\src\odbcsvn\trunk\lib\Debug\myodbc3.dll : fatal error LNK1120: 2 unresolved externals

How to reproduce:

use server version 5.0.45 (zip file, no install version from download site)
use odbc3.51.21r807 (from download site)

use cmake 2.4.7, vs 2003 .net v7.1.6030
follow the BUILD.win in myodbc source dir and use cmake to generate solution file. omitting QT library.

in vs2003, choose project myodbc3, build.... error appears

My Doubt:
it's a bug in mysqlclient.lib, 
Can anyone please confirm (or disconfirm) this and give suggestions?

Additional info:
Link parameters in vs2003

All Options:

/OUT:"C:\download\src\odbc3.51.21r807\lib\Debug\myodbc3.dll" /VERSION:0.0 /INCREMENTAL /NOLOGO /LIBPATH:"C:\download\src\mysql5.0.45\lib\opt\Debug" /LIBPATH:"C:\download\src\mysql5.0.45\lib\opt" /LIBPATH:"..\lib\Debug" /LIBPATH:"..\lib" /DLL /DEF:"C:\download\src\odbc3.51.21r807\driver\myodbc3.def" /DEBUG /PDB:"C:\download\src\odbc3.51.21r807\lib\Debug\myodbc3.pdb" /IMPLIB:"C:\download\src\odbc3.51.21r807\lib\Debug\myodbc3.lib" kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib user32.lib advapi32.lib wsock32.lib ws2_32.lib myodbc3u.lib mysqlclient.lib odbc32.lib odbccp32.lib

Additional Options:

/STACK:10000000 /machine:I386 /debug
[2 Nov 2007 4:29] Tom Donovan
Building 5.0.48 requires getting the source via BitKeeper, 
  see http://dev.mysql.com/doc/refman/5.0/en/installing-source-tree.html

This error message appears to have been fixed for mysqld in 5.0.44 

The fix for client apps (like ODBC) which link with mysqlclient.lib was not made until Aug 16, 2007, so it is not fixed in the 5.0.45 mysqlclient.lib.
   search for "+#ifdef HAVE_PTHREAD_KILL"

The client fix just suppresses the message for platforms which don't have HAVE_PTHREAD_KILL (like Windows).  The driver still pauses on exit for 5 seconds waiting for all the threads to end.

As a temporary measure to use Connector/ODBC 3.51.21 you could:
* put the #ifdef around lines 181-184 in the MySQL 5.0.45 source file: mysys\my_thr_init.c
* re-build MySQL to create a new mysqlclient.lib
* re-link myodbc3 with this new mysqlclient.lib
[27 Dec 2007 1:59] Vladimir Shebordaev
I get the same faulty error message on my win2k under MinGW with libmysql.dll from both recent 5.1.22-rc and 5.0.45 official windoze builds. There is no such an issue with libmysqlclient_r at least on Linux.
[31 Dec 2007 14:39] Tonci Grgin
This should be a duplicate of Bug#25621.
[3 Jan 2008 1:28] ming lu
Is this a duplicate bug?
Bug #25621 had been closed, why the same error still occur in mysql server 5.1.21&5.1.22 ?
[3 Jan 2008 9:04] Tonci Grgin
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release.

If necessary, you can access the source repository and build the latest available version, including the bug fix. More information about accessing the source trees is available at


C:\mysql507\mysql-5-1-23-BK\bin>mysql -uroot -p test
Enter password: ********
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.23-beta Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> ByeAborted