Bug #64466 Myodbc linux: Error in my_thread_global_end() and threads
Submitted: 27 Feb 2012 11:58 Modified: 23 Apr 4:37
Reporter: Pierre MARC Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / ODBC Severity:S1 (Critical)
Version:05.01.0010 OS:Linux (Not tested on other OS)
Assigned to: Bogdan Degtyariov CPU Architecture:Any
Tags: my_thread_global_end, MyODBC, threads

[27 Feb 2012 11:58] Pierre MARC
Description:
When we open a connection from one thread and close it from another thread we get the message:
 
Error in my_thread_global_end(): 1 threads didn't exit
 
We don’t know what are the consequences of this situation but I’m afraid that it produces some kind of instability and/or memory leak.
 
We use the odbc driver with a framework that creates pool of connections and several threads can access the odbc connection (one at a time because its synchronized). Sometimes because of time outs, the connection needs to be closed and reopened by the thread. So this bug is for us a blocking situation.
 
Attached is a simple program that reproduces the issue. Just compile it on linux. The usage is:
 
testodbc2 -s DataSource -u User [-p Password]
 
Here is the report on my test machine:
 
Open db source TEST from thread 1720362784
Source successfully connected
Database name: MySQL
Database version: 5.0.51a-community-nt-log
Driver name: libmyodbc5.so
Driver version: 05.01.0010
Driver ODBC version: 03.52
Close db source from thread 1685018368
Error in my_thread_global_end(): 1 threads didn't exit
Source successfully disconnected
 
I tried with a 3.51 driver and the result is the same.

How to repeat:
Open a connection from one thread and close it from another thread. The attached source file reproduces the issue.
The usage is:
 
testodbc2 -s DataSource -u User [-p Password]
 
Here is the report on my test machine:
 
Open db source TEST from thread 1720362784
Source successfully connected
Database name: MySQL
Database version: 5.0.51a-community-nt-log
Driver name: libmyodbc5.so
Driver version: 05.01.0010
Driver ODBC version: 03.52
Close db source from thread 1685018368
Error in my_thread_global_end(): 1 threads didn't exit
Source successfully disconnected
[27 Feb 2012 12:00] Pierre MARC
Small program that reproduces the issue (tried on linux)

Attachment: testodbc2.zip (application/x-zip-compressed, text), 2.48 KiB.

[27 Feb 2012 17:02] Valeriy Kravchuk
Isn't it a server bug (fixed in 5.0.70+)? See bug #37226.
[27 Feb 2012 17:40] Pierre MARC
I dont think this is the same bug. The bug #37226 was a windows one and for libmysql not for the odbc connector. The bug I reported occurs on the last version of the linux odbc connector. The program I attached to the case reproduces it. I got this bug on 32 and 64 bit linux machines.
[7 Mar 2012 5:31] Bogdan Degtyariov
Verified
[9 Jul 2012 14:35] Patrick Middleton
Seeing this on MacOSX 10.4.11/ppc with a self-built v5.1.10 connector.
[15 Apr 2013 15:35] Michael Koenig
We have the same bug with more recent versions of MySQL. We used a custom-compiled unixODBC 2.3.1 on Open Suse 11.3 to reproduce the issue. Here is the report as generated by Pierre's program:

Open db source MySQL R&D test database from thread -1346640096
Source successfully connected
Database name: MySQL
Database version: 5.0.87-community
Driver name: libmyodbc5w.so
Driver version: 05.02.0004
Driver ODBC version: 03.52
Close db source from thread -1387923712
Error in my_thread_global_end(): 1 threads didn't exit
Source successfully disconnected

Program terminated successfully
[28 Aug 2014 14:29] Ralf Mitschke
Is there any update on this bug?
I can confirm this issue still exists with MySQL drivers in versions 5.1.13 and 5.2.7. on SLES11.
[25 Oct 2015 20:48] Silviu Caragea
Hello,

I tested with the last driver and seems the issues is still there ?
Any idea when a fix will be available ? Or what effects has this bug over a production system ? memory leaks, crashes ?

Output is here:

./testodbc2 -s test
Open db source test from thread 1259255616
Source successfully connected
Database name: MySQL
Database version: 5.6.26-74.0-56
Driver name: libmyodbc5w.so
Driver version: 05.03.0004
Driver ODBC version: 03.52
Close db source from thread 1214273280
Error in my_thread_global_end(): 1 threads didn't exit
Source successfully disconnected

Silviu
[23 Apr 4:37] Bogdan Degtyariov
Posted by developer:
 
The bug is no longer repeatable with ODBC driver version 8.4.0:

Open db source test from thread -351987904
Source successfully connected
Database name: MySQL
Database version: 8.3.0-commercial
Driver name: libmyodbc8w.so
Driver version: 08.04.0000
Driver ODBC version: 03.52
Close db source from thread -387975488
Source successfully disconnected

Closing the ticket.