Summary:ASTERISK-04628: asterisk freeze if mySQL server unreachable
Reporter:Matthew Simpson (matthewsimpson)Labels:
Date Opened:2005-07-19 17:31:00Date Closed:2011-06-07 14:10:29
Versions:Frequency of
Description:If mySQL server dies/unreachable, Asterisk freezes and has to be kill'ed -9.  


I will pay a bounty to anyone willing to fix this steaming pile.  For bounty to be paid:

* patch must be entered into CVS-HEAD

* patch must be able to gracefully handle a SQL server going away. I'm open to ideas on how best to do this, but at a minimum no CDRs should be lost [cached somewhere until SQL write can occur], and there should be a way to poke the CDR_mysql process to attemt to make a new connection to mysql and start processing CDRs again if a replication slave has to take over processing

* patch should move CDR processing out of main asterisk thread to keep problems from hosing asterisk

email me at matthew@txlink.net to set up payment arrangements and value of bounty.
Comments:By: Tilghman Lesher (tilghman) 2005-07-19 18:20:55

What is the last console output prior to the freeze you are seeing?

By: Tilghman Lesher (tilghman) 2005-07-19 18:21:38

Also, this is not MAJOR, as this module is an addon, not part of the core.

By: Matthew Simpson (matthewsimpson) 2005-07-19 21:49:11

there is no last console output, because asterisk freezes.

I didn't put MAJOR, I put "CRASH".

By: Tilghman Lesher (tilghman) 2005-07-19 22:42:15

So you have a blank console?  Nothing on it at all?  I find that rather unbelievable.

By: Brian West (bkw918) 2005-07-20 10:17:57

why not attach to it with gdb and get a "thread apply all bt"


By: Matthew Simpson (matthewsimpson) 2005-07-20 10:33:02

I am pretty sure there was another bug report in the past about this.  I believe the reason asterisk freezes is because the cdr_mysql thread locks all the other threads, and since it can't complete, it locks asterisk.

If I connect to the console with asterisk -vvvr there is nothing, even a stop now will not do anything.  The only way to resolve is to kill -9.

I am not familiar with asterisk code but 1) cdr processing should not lock all threads and 2) cdr_mysql needs to be able to gracefully handle this condition

If one has a cluster of * all dumping cdrs to mysql, then this bug will nuke the entire cluster.

By: Tilghman Lesher (tilghman) 2005-07-20 11:15:12

What exactly do you think it is locking that prevents other threads from executing?

By: Michael Jerris (mikej) 2005-07-20 12:07:17

we need a thread apply all bt as bkw has requested to look at this further.  That being said, there is already functionality in head that uses a seperate thread to send cdr to the db, try the settings for batching cdr to see if it helps with this issue.

By: Matthew Simpson (matthewsimpson) 2005-07-20 21:36:58

i am running latest -HEAD, what config file has setting to batch cdr?

By: Michael Jerris (mikej) 2005-07-20 22:48:59

batch= in cdr.conf.  look at the sample conf in current head.

By: Michael Jerris (mikej) 2005-07-31 21:32:35

suspended due to no resoinse.  If you are still having this issue we need the requested information to debug this.  Feel free to re-open this issue if it still exists when you have the requested information.  Thanks

By: Ksenia (ksy) 2012-09-20 06:59:50.311-0500

I have a similar issue - when mySQL server becomes unreachable, it's impossible to make and take calls. Only unloading of cdr_mysql module helps while the server is unreachable. When I connect to the console of course there are messages like 'cannot connect to database ...'. I can provide any information which can be helpfull to resolve this issue. I'm using asterisk on Gentoo.