[SR-Users] SQLOPS sql_query_async() not functioning in an async manner?

Alex Balashov abalashov at evaristesys.com
Wed Feb 23 03:06:42 CET 2022


Is there a difference in how it behaves when:

a) A database that was previously reachable becomes unreachable or unresponsive? vs. 

b) A db_url that is not reachable in principle?

— Alex

> On Feb 22, 2022, at 7:11 PM, Ben Kaufman <bkaufman at bcmone.com> wrote:
> 
> I’m not sure if this is by design or not.  I have things I want to log to a SQL DB, but it’s not nearly as important as call handling, so the sql_query_async() function looked ideal, but in testing, if the DB is not responsive, the call processing gets blocked.  In the example below, I’m using just a short hostname which isn’t resolvable, but if I have an IP address there that isn’t really assigned (for example if the DB server is down), the same blocking behavior is exhibited, but the error is slightly different (can’t connect instead of unknown host).  
>  
>  
>  
> Here’s my config.  This specific simple config was tested on Kamailio 5.5, but I observe similar behavior (in a more complicated config) in the dev branch as well.
>  
>  
> - - - - 
>  
> #!KAMAILIO
>  
> async_workers=2
>  
> loadmodule "db_mysql"
> loadmodule "sqlops"
> loadmodule "sl"
> loadmodule "xlog"
> loadmodule "pv"
>  
> force_rport=yes
>  
> ## Host sql does not resolve.
> modparam("sqlops","sqlcon","cb=>mysql://kamailio:kamailiorw@sql/kamailio")
> ## But start anyways.
> modparam("sqlops", "connect_mode", 1)
>  
> request_route {
>     sl_send_reply("100", "Trying"); ## Prevent re-transmissions from the UAC
>  
>     xlog("L_NOTICE", "Time before sql_query_async(): [$TV(Sn)]\n");
>     sql_query_async("cb", "INSERT INTO table1 (col) VALUES ('val')");
>  
>     xlog("L_NOTICE", "Time before sl_send_reply(): [$TV(Sn)]\n");
>     sl_send_reply("404", "Not found");
> }
>  
>  
> Here’s the log if I send a simple INVITE with SIPp. Note the timestamps
>  
> 9(16) NOTICE: <script>: Time before sql_query_async(): [1645574694.546165]
> 9(16) ERROR: db_mysql [km_my_con.c:163]: db_mysql_new_connection(): driver error: Unknown MySQL server host 'sql' (-3)
> 9(16) ERROR: <core> [db.c:319]: db_do_init2(): could not add connection to the pool
> 9(16) ERROR: sqlops [sql_api.c:190]: sql_reconnect(): failed to connect to the database [cb]
> 9(16) ERROR: sqlops [sqlops.c:232]: sql_check_connection(): failed to connect to database
> 9(16) ERROR: sqlops [sqlops.c:264]: sql_query_async(): invalid connection to database 9(16) NOTICE: <script>: Time before sl_send_reply(): [1645574699.552440]
>  
>  
>  
>  
>  
>  
>  
> Ben Kaufman
> Sr. VoIP Engineer - BCM One
>  
> +1.612.735.9309
> bkaufman at bcmone.com
> 24 hour client support: +1.855.639.6300
>  
>        
>  
> NOTE: This e-mail and any attachments are from BCM One, Inc. and are intended
> solely for the use and review of the individual(s) to whom it is addressed.
> If you believe you received this e-mail in error, please notify the sender
> immediately, delete the e-mail (and any attachments) from your computer and do
> not copy or disclose it to anyone else.
>  
> __________________________________________________________
> Kamailio - Users Mailing List - Non Commercial Discussions
>  * sr-users at lists.kamailio.org
> Important: keep the mailing list in the recipients, do not reply only to the sender!
> Edit mailing list options or unsubscribe:
>  * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users

-- 
Alex Balashov | Principal | Evariste Systems LLC

Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free)
Web: http://www.evaristesys.com/, http://www.csrpswitch.com/




More information about the sr-users mailing list