MySQL or RTP port socket issue?

We use mysql to update status of a call using the built in mysql functions. We currently have been trying to switch to a different SIP provider for outgoing calls but once we hit a higher call volumes things start to go bad. Mysql deadlocks records and asterisk spits out a bunch of errors. Can’t figure out what side is the problem exactly except to think its the provider since it doesnt seem to happen on the original provider.

MySQL:
From what we can tell, the main source of sql trouble is around this deadlocking " Query SELECT LAST_INSERT_ID() AS last FROM table" which is autoincrement feature. It causes these errors:

WARNING[29079] app_mysql.c: mysql_real_connect(mysql,server,user,pass,DB,…) failed(2003): Can’t connect to MySQL server on ‘server’ (111)
WARNING[28766] app_mysql.c: aMYSQL_query: mysql_query failed. Error: MySQL server has gone away

RTP issue:
Getting tones of these errors once its starts going bad but mostly the last 4 errors.
ERROR[22211] res_rtp_asterisk.c: RTCP SR transmission error to 4.55.38.70:6257, rtcp halted Operation not permitted
ERROR[22211] res_rtp_asterisk.c: RTCP SR transmission error to 208.93.47.133:6699, rtcp halted Operation not permitted
ERROR[27394] acl.c: Cannot create socket
ERROR[27394] chan_sip.c: Got SDP but have no RTP session allocated.
WARNING[27394] res_rtp_asterisk.c: Unable to allocate RTP socket: Too many open files
WARNING[27394] chan_sip.c: Autodestruct on dialog ‘39e967dd6619b35941c7ce1477da4794@SERVERIP:5060’ with owner in place (Method: BYE)

Are the calls failing at a high rate causing mysql to execute all the failed queries at once locking up mysql? There are a couple queries that happen on the h extension in the context.
Any help on what exactly the RTP issues are having problems with?

Hi,

The error “Unable to allocate RTP socket: Too many open files” is because you have run out of available file descriptors. See here how to increase maximum open files limit.

As to the MySQL issue it is difficult to say anything without seeing your queries/dialplan first.

are you closing you connection properly to mysql ?

Ian