Summary:ASTERISK-14092: If the database loses connection for a few seconds, no cdr gets written ever
Reporter:Private Name (falves11)Labels:
Date Opened:2009-05-08 01:19:23Date Closed:2011-06-07 14:00:23
Versions:Frequency of
Description:This is a major and potentially very costly problem with cdr_adaptive. Suppose I close the firewall in the database (SQL 2005) for 10 seconds. Then no CDR gets saved to the database ever. ODBC keeps working, I mean, it bounces back, because successive calls to func_odbc do work. But cdr_adapative does not any reseiliance, it just never writes a cdr anymore. It happpened to me twice alrfeady in production.


just start asteris, then pleace a call, see that the cdr record was saved, then restart sql, and even if asterisk is running fine, no cdr ever will be posted.
Comments:By: Tilghman Lesher (tilghman) 2009-05-08 11:12:32

I just tried this with a MySQL backend, and it works.  So it looks like it's a problem with your FreeTDS backend, again, and not with Asterisk.

By: Tilghman Lesher (tilghman) 2009-05-08 11:15:32

Just for the sake of posterity, here are my log lines:

[May  8 11:11:04] WARNING[13130]: res_odbc.c:616 ast_odbc_prepare_and_execute: SQL Execute returned an error -1: HY000: [MySQL][ODBC 3.51 Driver][mysqld-5.0.51a-3ubuntu5.4]MySQL server has gone away (78)
[May  8 11:11:04] WARNING[13130]: res_odbc.c:628 ast_odbc_prepare_and_execute: SQL Execute error -1! Attempting a reconnect...
[May  8 11:11:04] WARNING[13130]: res_odbc.c:723 ast_odbc_sanity_check: Connection is down attempting to reconnect...
Error in my_thread_global_end(): 1 threads didn't exit
[May  8 11:11:09] DEBUG[13130]: res_odbc.c:1388 odbc_obj_disconnect: Disconnected 0 from asterisk [mysql-asterisk]
[May  8 11:11:09] DEBUG[13130]: res_odbc.c:1396 odbc_obj_disconnect: Database handle deallocated
[May  8 11:11:09] NOTICE[13130]: res_odbc.c:1423 odbc_obj_connect: Connecting asterisk
[May  8 11:11:09] NOTICE[13130]: res_odbc.c:1451 odbc_obj_connect: res_odbc: Connected to asterisk [mysql-asterisk]

By: Private Name (falves11) 2009-05-13 20:15:38

Dear tilghman
I would like to show you the issue: res_odbc reconnects, but cdr_adaptive never sends any records again. Let me try to explain myself better. I start Asterisk with a SQL Server login disabled. Asterisk loads and cannot connect to the database. Then I enable the login. Func_odbc starts working, and the calls are being routed, so res_odbc reconnected fine, as per your own trace.  But cdr_adaptive never stores any records. Even if I do a "module reload cdr_adaptive.so", the records never get recorded. I have to restart Asterisk to get any cdr back in. This is a very dangerous situation, since if the database has any glitch or discontinuity, we can run for hours without CDR and lose tons of money. The fact that func_odbc does work proves that the issue is not in the ODBC or freetds stack, it is confined to cdr_adaptive. It happenned today again to me. Please contact me at falves1@hotmail.com and if you log into my windows box and watch the sql debugger you will see the issue rigght away.

By: Tilghman Lesher (tilghman) 2009-05-15 10:10:17

Again, there is nothing I can do about this, because I cannot reproduce the issue.  You'll need to workup a repeatable case for me to be able to track this down, preferably with a non-MS-SQL-Server connection (mysql or postgres).  I can leave this open for another 5 days, but if you cannot create such a case, this bug will again need to be closed.

By: Private Name (falves11) 2009-05-15 10:13:07

I will update a debug trace.

By: Tilghman Lesher (tilghman) 2009-05-20 16:55:15

Closed after 5 days.