I am calling a lua script from dialplan which does following steps ...

1- Gets freeswitch dbh handle (odbc mysql)
2- Runs a mysql stored procedure which returns balance remaining amount for the subscriber who made call.
3- Save the amount in session variable and released dbh handle
4- Play sound files as per output received and saved in step 3

Now upto 200 calls and first 2-3 hours of start all work fine. I can see in Database that script uses 32 connections approx at a given time (I think connection pooling works) but suddenly connections start increasing and go upto 300+ and because of that database stops responding and i have to kill freeswitch to make production DB responsive again.

I am not sure where and what I should check. Can someone give me pointers on what I can check?..Or I am doing something fundamentally wrong.

Can there be such a case where lua scripts hang and never release connection?