Summary:ASTERISK-25963: func_odbc requires reconnect checks for stale connections
Reporter:Ross Beer (rossbeer)Labels:
Date Opened:2016-04-26 08:55:57Date Closed:2016-04-28 06:52:45
Versions:13.9.0 Frequency of
Environment:Cent OS 7Attachments:( 0) func_odbc_connection_check.diff
( 1) ODBC_CLI.txt
Description:ODBC queries are no longer working for any queries. It appears that the database connection can not connect:

[2016-04-26 13:55:13] WARNING[19126][C-0000000f]: func_odbc.c:349 generic_execute: SQL Execute returned an error -1: 08S01: [MySQL][ODBC 5.3(w) Driver][mysqld-5.5.5-10.0.21-MariaDB-wsrep]MySQL server has gone away (89)

This is for all queries, rolling back to an earlier version of asterisk resolves the issue.
Comments:By: Asterisk Team (asteriskteam) 2016-04-26 08:55:58.599-0500

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

By: Rusty Newton (rnewton) 2016-04-26 09:24:15.139-0500

Can you provide:

* Versions of MariaDB, odbc driver, etc.
* What earlier Asterisk version that you rolled back to.
* A larger excerpt of debug with DEBUG messages included (turned up to debug level 5 or higher)?

By: Ross Beer (rossbeer) 2016-04-26 09:31:02.528-0500

Latest UnixODBC, Latest MySQL ODBC drivers and MariaDB 10. These were upgraded to resolve the issue with the res_odbc in the earlier version.

This issue has only started after the commit 2682

If we roll back to 13.8.2 the issue is resolved.

By: Mark Michelson (mmichelson) 2016-04-26 10:14:34.027-0500

Looks like the connection is going stale, so some reconnect checks are needed. I can put together a patch for you to test.

By: Mark Michelson (mmichelson) 2016-04-26 11:43:13.767-0500

I'm attaching func_odbc_connection_check.diff. This attempts to check if the connection is dead, and if it is, it will create a new connection and carry on.

By: Rusty Newton (rnewton) 2016-04-26 18:14:17.104-0500

Setting this to Waiting on Feedback.

By: Ross Beer (rossbeer) 2016-04-27 03:50:41.148-0500

The patch provided resolves the issue. I will continue to monitor to see if the issue occurs again.

Thank you for the quick fix