Linux, ODBC and MySQL connector

Added by Lionel Martin about 12 years ago

We have some issues with MySQL ODBC driver on Linux.

We ran on fatal crash issues with the base driver of our linux distribution, so we installed the latest one as Nirva adviced us to do.

So we have now MySQL ODBC connector version 5.1.10.

There are no longer fatal crash issues, but we still have sometimes a warning message of the MySQL driver when stopping sessions that used database connections: Error in my_thread_global_end(): xx threads didn't exit.

We believe it may be linked to our management of the sessions DB pool:
- we open the connection when the DB session is asked to do a query
- the db connection may timeout. In that case, and if the db session is to be used, we re-open (DATABASE:SOURCE:OPEN) the db connection, after closing the previous one (DATABASE:SOURCE:CLOSE)
- when application is stopped, the db sessions are automatically stopped by Nirva server, but we do not have a close session procedure that calls explicit DATABASE:SOURCE:CLOSE.

Since there is no explicit close on db connection at the application stop, could the message come from there ?
We will implement the fix to close db connections on named sessions close shortly.
Anyway, we thought that on session close DATABASE service would release all remaining connections. In this case, the above fix will not change anything.

We looked on Internet for such existing problems, and found some that should have been fixed in the version we use.
Is it possible that the DATABASE service does not handle the ODBC connection correctly ?

Any help will be greatly appreciated.

Thank you


Replies (8)

RE: Linux, ODBC and MySQL connector - Added by Pierre Marc about 12 years ago

Hi Lionel,

Nirva properly closes all the database connections owned (opened) by a session when this one terminates. Adding an explicit DATABASE:SOURCE:CLOSE would not change the problem. The issue seems to be a know one for the linux mysql odbc driver but should have been corrected in version 5.1.9 of the driver. Now I suspect that there is still some instability in this part of the driver.
There is nothing we can do at this level on the database service itself.
You can try to play on the mysql parameter for time outs. You can also try to "refresh" the existing connections using a Nirva listener in order to avoid them going into time out. You can set the odbc trace file to see if there is some specific context where this problem occurs.
In the Nirva context, database connections can be opened by a thread and closed by another one and maybe the driver doesn't manage correctly that.
You can try the following tests in order to attempt reproducing the issue: open a database connection from a named session created at application start time, then try to close and re-open this db connection. If it works, do the same but after changing the time out of mysql connection (on mysql side).
We'll try to do the same tests on our side.
Question, do you have the same issue on a 32 and 64 bits environments ?

RE: Linux, ODBC and MySQL connector - Added by Lionel Martin about 12 years ago

Thank you Pierre for your answer.

I'll try to do the test in the morning, and will keep you posted.

We have the same issue on both 32 and 64 bits environments.

RE: Linux, ODBC and MySQL connector - Added by Lionel Martin about 12 years ago

I reproduce now the issue on a "simple" test. It involves sessions names, and several threads using the same ODBC connection I guess.

After several tests, I finally added the property Threading = 2 to the driver in the odbcinst.ini file to turn multi-threading off at the ODBC manager level, but the message still occures.
I have not tried the timeouts, since I am able to reproduce the bug in 1 procedure execution (few seconds). I believe it has nothing to do with the timeout.

I also parametrized log files, but they don't display any error.

I'm afraid that the problem really is about the driver not handling correctly the fact that a thread opens a connection, and another thread closes it.

RE: Linux, ODBC and MySQL connector - Added by Pierre Marc about 12 years ago

At this step, it should be usefull to try reproducing the issue outside the Nirva context area in order to post a bug report to mysql. I can do that but I need to be sure of the origin of the issue and to do some tests before. How do you reproduce it with the minimum material ?

RE: Linux, ODBC and MySQL connector - Added by Lionel Martin about 12 years ago

Attached to this message is an application package containing a minimalist way to reproduce the problem.

It contains an init.nvp script that calls a open_named.pl script to create 2 named sessions for a db pool at application start.
It also contains 3 scripts:
  • test_db_open: script to close and open a database connection
  • test_db_parallel_tasks: script that asks for a named session and calls previous script in the named session
  • test_db_named: script that asks for a named sessions and calls script to close and open database connection in it. It also calls in threads the previous script 2 times to simulate several concurrent connections.
Environment used:
  • Linux 32bits (We had a similar issue on a Linux 64bits environment, but I have not tested this application on it)
  • ODBC configuration for MySQL using the latest ODBC connector (5.1.10)
  • Nirva Server launched with -c -v and -t parameters
Steps to reproduce:

Thank you very much for your help!

nirva_app_BUG_ODBC-v0_1_0.pkg - Application BUG_ODBC to reproduce the problem (1.23 KB)

RE: Linux, ODBC and MySQL connector - Added by Pierre Marc about 12 years ago

Hi Lionel,

Thanks for your code to reproduce the issue. I was able to reproduce it on my side. This error is not a Nirva error so I will not post a bug for it. This is a mysql odbc driver error. In fact the driver displays the message "Error in my_thread_global_end()" when a thread is opening a connection and another one is closing it. This situation may occur with Nirva especially when using database connection pool with named sessions.
We are going to post a bug report to MySql. For now, we cannot validate this driver with Nirva. There is a MySql driver provided by DataDirect but it's not free. We will test it and come back to you.
I attach a zip file containing a small program to reproduce the issue on linux. The usage is "testodbc2 -s DataSource -u User [-p Password]".

testodbc2.zip - Program to reproduce the issue from outside Nirva context. (2.48 KB)

RE: Linux, ODBC and MySQL connector - Added by Lionel Martin about 12 years ago

Hi Pierre

Thank you for your help.
I confirm your little program reproduces the bug on my environment.

I will look for DataDirect solutions.
Thank you for your help

RE: Linux, ODBC and MySQL connector - Added by Lionel Martin about 12 years ago

Juste for information, here is a link to the mysql bug: http://bugs.mysql.com/bug.php?id=64466

(1-8/8)