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

Ben Kaufman bkaufman at bcmone.com
Wed Feb 23 01:11:22 CET 2022


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<mailto:bkaufman at bcmone.com>
24 hour client support: +1.855.639.6300

[https://www.bcmone.com/files/bcmone-logo.png]<https://www.bcmone.com/>   [https://www.bcmone.com/files/twitter-icon-circle.png] <https://www.facebook.com/bcmonenyc/>   [https://www.bcmone.com/files/twitter-icon-circle.png] <https://twitter.com/bcm_one/>   [https://www.bcmone.com/files/linkedin-icon-circle.png] <https://www.linkedin.com/company/business-communications-management/>

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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20220223/9e3f54f2/attachment.htm>


More information about the sr-users mailing list