Summary:ASTERISK-06378: cdr_odbc created lots of connections to db
Reporter:peter (peter)Labels:
Date Opened:2006-02-20 17:38:51.000-0600Date Closed:2006-04-19 13:46:16
Versions:Frequency of
Environment:Attachments:( 0) 20060405.patch
( 1) 20060413__bug6553.diff.txt
Description:If there is a failure in inserting a record into the cdr table, it appears to
start another connection to the db without disconnecting the last connection.

We had a corrupt cdr database.  When tring to insert a record an error would
return, and the cdr_odbc would create another connection and try again.  Only
to fail again.

We had a large number of connections on our db server.  Once the cdr table was fix
and asterisk restarted everything was back to normal.
Comments:By: Olle Johansson (oej) 2006-04-04 08:35:50

We need odbc coders for this one.

By: Olle Johansson (oej) 2006-04-04 08:36:08

Can you repeat this? Can anyone else repeat this?

By: alric (alric) 2006-04-04 13:34:13

I believe I know the method to repeat this, albeit not a friendly one :)

Setup ODBC to connect to MySQL, then full the HD the MySQL dbs are stored on.  cdr_odbc will attempt to put in the records but fail, and eventually the cdr table will get corrupted.  We saw the excess of connections as well on a server where this happened.

By: peter (peter) 2006-04-04 17:21:55

What I have done to replicate this problem is to have a connection to MySQL.  With the mysql table manually locked, I manually edit the cdr.MYD to corrupt the file.  And unlock the table.  Any inserts will return an error message.

I have also been looking into the code.

I think all that needs to be done is it add a SQLDisconnect(ODBC_con), before the SQLConnect in odbc_init().

But I haven't had enough time to test it yet, or check to see if it is even a good idea.

By: peter (peter) 2006-04-05 18:55:56

I have made a patch the that fixes the problem.  It also appears that this section of code was also leaking memory everything this bug had happened.

Disclaimer faxed in.

By: Tilghman Lesher (tilghman) 2006-04-13 16:17:18

There were more memory leaks.  Please test.

By: peter (peter) 2006-04-19 12:33:35

It is working for me.

By: Tilghman Lesher (tilghman) 2006-04-19 13:46:16

Committed to 1.2, not in trunk (trunk was revamped recently)