0

I have this question asked but after a deeper investigation I realized that hanging is not the issue. After reading this thread I decided to ask a new question.

For example I pass this string to the mysql_query() function:

SELECT 1

When I run several thousand of this command via mysql_query() then the command is NOT submitted to the MySQL server!

I checked the MySQL log file and I couldn't believe it but the command wasn't there and therefore the mysql_query() does never return because it doesn't receive any answer from the server.

MySql is writing the command into the log file BEFORE it gets executed. I tried it with SELECT SLEEP(10).


Note:

I know, it does mean that much but it was working for 3 years without any issue on SLES 11.3/XenServer 6.5. Note: This is an MCVE where it doesn't work as well!

Since I moved it to SLES 12.3 and XenServer 7.4 the problems started.

The C++ code is very simple - I have checked it for 3 weeks before I wrote this question. The point is that this issue starts after ~10k queries. The VM has still ~3 GB RAM free.


Note regarding an MCVE:

I created an MCVE which works for more than 500k executions of the MySQL command.

When I insert this MCVE code into my project and comment my existing main() in order to execute the main function from the MCVE then after few thousand [or even only hundred] of executions suddenly the MySQL command is again not submitted to the MySQL server.

To be more specific: Only static objects of my project are initialized before the embedded MCVE runs.

This must be something very strange regarding these static initializations because no other line of code is running.


Question:

Any idea what is going on? Especially the fact that the command is apparently [why should I doubt the MySQL Server log file] not submitted from the C API client to the MySQL server is really disturbing me.


Technical data:

  • SLES 12.3 running on XenServer 7.4 as VM
  • Compiled with gcc 7.3 using -std=c++17 and almost every warning option.
  • Using the default SLES 12.3 glibc 2.22 with all SLES updates installed.
  • Connecting to MySQL Community Server 5.7.21
  • C API client 5.7.21
  • If you are using InnoDB, you should not auto-reconnect. Why? Because you risk rolling back a half-finished transaction, then COMMITting the other half -- leading to silent data corruption. – Rick James Jun 4 '18 at 22:08
  • What happens with the even simpler SQL: SELECT 1 ? This would avoid the unknown factor of pounding on settings (@@). – Rick James Jun 5 '18 at 13:14
2

User Gerard H Pille gave me the correct tip - see the chat.

I had to remove the MYSQL_OPT_RECONNECT setting and now it works. The program runs now for more than 2 months without any issue1.

It were these 2 lines of code according to the MCVE:

bool autoReconnectMySQL = true;
mysql_options( mysqlConnection, MYSQL_OPT_RECONNECT, &autoReconnectMySQL );

Why the setting is causing this issue I cannot answer.

New test results: MySQL C API 8.0.11 doesn't have this issue anymore.


1 Now, it runs for more than 1 year without any problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.