Bug #75002 assert triggered in ssps_close when mysql gone away
Submitted: 26 Nov 2014 0:09 Modified: 11 Jan 2016 19:24
Reporter: Alan Wood Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / ODBC Severity:S1 (Critical)
Version:5.2.7,5.3.* OS:CentOS
Assigned to: CPU Architecture:Any

[26 Nov 2014 0:09] Alan Wood
Description:
Trying to send a new query over a connection when the mysql server has been restarted should result in a 'mysql has gone away' error. Instead we get an assertion from within ssps_close() causing the calling program to exit.

How to repeat:
We are repeating this from a calling Cobol program, so not too sure of the exact calling convention.
 1) open connection
 2) send query ( must be a preparable statement )
 3) restart mysql server
 4) send another query.
  ---  assert triggered 

Suggested fix:
Ignore return from mysql_stmt_close() in ssps_close. ssps_close() seems to only be called to clear out the old prepared statement and errors in the connection will be detected very soon afterwards.
Alternatively the error return could be returned to the library caller.
[13 Jan 2015 6:50] Chiranjeevi Battula
Hello Alan Wood,

Thank you for the bug report.
I tried to reproduce the issue at my end using Visual Studio 2013 (C#.Net), MySQL Connector/ODBC 5.3.4 but couldn't trace out any issue in assert().
Could you please list out the steps you tried out at your end? Please provide repeatable test case in order for us to confirm this issue at our end.

Thanks,
Chiranjeevi.
[13 Jan 2015 9:22] Alan Wood
Hi Chiranjeevi Battula,
 We use Linux most of the time here so providing test scripts for windows from scratch would be difficult. If you could send me a complete project for VS2010 or even VS2013 which sends a query via the ODBC connector then I should be able to add a test program that demonstrates this issue for Windows.
[1 Jun 2015 8:50] Chiranjeevi Battula
Hello Alan Wood,

Thank you for your feedback.
I could not repeat this issue at my end with the provided information. 
Could you please provide repeatable steps (Windows/Linux any OS would be fine) for us to confirm this issue at our end.

Thanks,
Chiranjeevi.
[16 Jun 2015 1:51] Alan Wood
test showing core dumping

Attachment: connection_lost.c (application/octet-stream, text), 2.15 KiB.

[16 Jun 2015 1:58] Alan Wood
Added test file. This is not complete yet as I am not sure what the correct result of the test should be. However core dumping is obviously not desired.
 The was run on Centos 7.1.  mysql-connector-odbc.x86_64.5.3.4-1.el7

result of running this is:
a.out: /export/home/pb2/build/sb_0-12449490-1403131948.34/rpm/BUILD/mysql-connector-odbc-5.3.4-src/driver/my_prepared_stmt.c:300: ssps_close: Assertion `!"Could not close stmt"' failed.
[30 Jul 2015 21:20] Alan Wood
This is becoming urgent as I have not been able to find source rpm for Centos7 to be able to build a workaround for this like I was able to with Centos/RHEL6. Would it be more sensible to change to mariadb to match the Centos distribution?
[11 Jan 2016 11:52] Chiranjeevi Battula
Hello Alan Wood,

Thank you for your feedback.
I could not repeat this issue at my end with the provided information. 
If you can provide more information, feel free to add it to this bug and change the status back to 'Open'.

Thank you for your interest in MySQL.

Thanks,
Chiranjeevi.
[11 Jan 2016 19:24] Alan Wood
Changing OS to CentOS. I doubt that this is repeatable on Windows ( MS builds ). Which OS was this regarded as not repeatable on?
I have managed to get a source RPM to build for CentOS7 with patch if anyone needs them.
[4 May 2021 23:09] Alan Wood
I can confirm that the changes I asked for here have been made.
They are in 8.0.23 and likely earlier.

Note that there are other places where assert() is used in library code and unless the linux build has been changed to a release build ( assert() not active ) then other related issues are likely to arise. An example that I have hit is assert(values) in ssps_get_out_params()