<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {mso-style-priority:99;
        mso-style-link:"Plain Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        color:black;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
tt
        {mso-style-priority:99;
        font-family:"Courier New";}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;
        color:black;}
span.PlainTextChar
        {mso-style-name:"Plain Text Char";
        mso-style-priority:99;
        mso-style-link:"Plain Text";
        font-family:"Calibri","sans-serif";}
span.EmailStyle22
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle23
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor="white" lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:#1F497D">Hi</span> <span style="color:#1F497D">
Răzvan ,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">Ok. I found this on the 2.2 release info page:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">2.27 DB_VIRTUAL module<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"> added async raw query support<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">I thought I might be able to wrap db_virtual around unixodbc and get it to work. Apparently not! Or, at least not yet.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">My application is to attempt to replace an aging Kamailio proxy with an OpenSIPS one in async mode. Unfortunately I don't have control over the data or where it lives; it's stuck in an MSSQL server. Actually,
in a few geographically distributed but otherwise equal MSSQL servers so the db_virtual layer was perfect.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">rest_get is mentioned as an available to async. I don't know much about rest but I'll look at writing a wrapper of sorts to get to the stored procedure that way. I'm open to any suggestions!
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">- Jeff<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="color:windowtext">From:</span></b><span style="color:windowtext"> users-bounces@lists.opensips.org [mailto:users-bounces@lists.opensips.org]
<b>On Behalf Of </b>Razvan Crainea<br>
<b>Sent:</b> Wednesday, September 07, 2016 4:07 AM<br>
<b>To:</b> users@lists.opensips.org<br>
<b>Subject:</b> Re: [OpenSIPS-Users] 2.2 crash with async, db_virtual and unixodbc<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><tt><span style="font-size:10.0pt">Hi, Jeff!</span></tt><span style="font-size:10.0pt;font-family:"Courier New""><br>
<br>
<tt>Unfortunately async operations are only supported by the MySQL backend, therefore it won't work with unixodbc or other backends. Now it crashes because of a mishandling in the db_virtual module. We are working on a fix for the crash, but even after the
fix, you will still be unable to run async queries with unixodbc.</tt><br>
<tt>If you really want to do it async, then you should use MySQL backend. Also, don't forget to open a feature request on the issues page[1] to support async queries for unixodbc.</tt><br>
<br>
<tt>[1] <a href="https://github.com/OpenSIPS/opensips/issues">https://github.com/OpenSIPS/opensips/issues</a></tt><br>
<br>
<tt>Best regards,</tt><br>
<br>
</span><span style="font-size:12.0pt"><o:p></o:p></span></p>
<pre>Răzvan Crainea<o:p></o:p></pre>
<pre>OpenSIPS Solutions<o:p></o:p></pre>
<pre><a href="http://www.opensips-solutions.com">www.opensips-solutions.com</a><o:p></o:p></pre>
<div>
<p class="MsoNormal">On 09/07/2016 04:16 AM, Jeff Pyle wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoPlainText">Hello,<o:p></o:p></p>
<p class="MsoPlainText"> <o:p></o:p></p>
<p class="MsoPlainText">I'm working from the 2.2 nightly build repo on Debian Jessie, 64-bit, specifically, 2.2.1~20160830~7261cf0-1.<o:p></o:p></p>
<p class="MsoPlainText"> <o:p></o:p></p>
<p class="MsoPlainText">I have a simple test script that runs a stored procedure on a Microsoft SQL 2014 server and xlogs the returned AVPs. This works fine. When I break it up into an async() function and a return route block, I get a crash every time.<o:p></o:p></p>
<p class="MsoPlainText"> <o:p></o:p></p>
<p class="MsoPlainText">Script:<o:p></o:p></p>
<p class="MsoPlainText"> <o:p></o:p></p>
<p class="MsoPlainText">route {<o:p></o:p></p>
<p class="MsoPlainText"> xlog("L_INFO", "Sending query...\n");<o:p></o:p></p>
<p class="MsoPlainText"> async(avp_db_query("exec dbo.doStuff '1','2','3','4'",<o:p></o:p></p>
<p class="MsoPlainText"> "$avp(db1);$avp(db2);$avp(db3)"), post_db_dip);<o:p></o:p></p>
<p class="MsoPlainText">}<o:p></o:p></p>
<p class="MsoPlainText"> <o:p></o:p></p>
<p class="MsoPlainText">route [post_db_dip] {<o:p></o:p></p>
<p class="MsoPlainText"> xlog("L_INFO", "Back from query.\n");<o:p></o:p></p>
<p class="MsoPlainText"> <o:p></o:p></p>
<p class="MsoPlainText"> while (is_avp_set("$avp(db1)") && is_avp_set("$avp(db2)") && is_avp_set("$avp(db3)")) {<o:p></o:p></p>
<p class="MsoPlainText"> xlog("L_INFO", "db1=$avp(db1), db2=$avp(db2), db3=$avp(db3)\n");<o:p></o:p></p>
<p class="MsoPlainText"> avp_delete("$avp(db1)");<o:p></o:p></p>
<p class="MsoPlainText"> avp_delete("$avp(db2)");<o:p></o:p></p>
<p class="MsoPlainText"> avp_delete("$avp(db3)");<o:p></o:p></p>
<p class="MsoPlainText"> }<o:p></o:p></p>
<p class="MsoPlainText"> <o:p></o:p></p>
<p class="MsoPlainText"> xlog("L_INFO", "End of processing.\n");<o:p></o:p></p>
<p class="MsoPlainText"> <o:p></o:p></p>
<p class="MsoPlainText"> sl_send_reply("600", "Road Closed");<o:p></o:p></p>
<p class="MsoPlainText"> exit;<o:p></o:p></p>
<p class="MsoPlainText">}<o:p></o:p></p>
<p class="MsoPlainText"> <o:p></o:p></p>
<p class="MsoPlainText">The debug=6:<o:p></o:p></p>
<p class="MsoPlainText"> <o:p></o:p></p>
<p class="MsoPlainText">...<o:p></o:p></p>
<p class="MsoPlainText">/usr/sbin/opensips[19887]: DBG:avpops:ops_async_dbquery: query [exec dbo.doStuff '1','2','3','4']<o:p></o:p></p>
<p class="MsoPlainText">/usr/sbin/opensips[19887]: DBG:db_virtual:db_virtual_async_raw_query: f call handle size = 1<o:p></o:p></p>
<p class="MsoPlainText">/usr/sbin/opensips[19887]: DBG:db_virtual:try_reconnect: try reconnect<o:p></o:p></p>
<p class="MsoPlainText">/usr/sbin/opensips[19887]: DBG:db_virtual:db_virtual_async_raw_query: flags1 = 3<o:p></o:p></p>
<p class="MsoPlainText">/usr/sbin/opensips[19883]: DBG:core:handle_sigs: status = 11<o:p></o:p></p>
<p class="MsoPlainText">/usr/sbin/opensips[19883]: <a href="INFO:core:handle_sigs">
INFO:core:handle_sigs</a>: child process 19887 exited by a signal 11<o:p></o:p></p>
<p class="MsoPlainText">/usr/sbin/opensips[19883]: <a href="INFO:core:handle_sigs">
INFO:core:handle_sigs</a>: core was not generated<o:p></o:p></p>
<p class="MsoPlainText">/usr/sbin/opensips[19883]: <a href="INFO:core:handle_sigs">
INFO:core:handle_sigs</a>: terminating due to SIGCHLD<o:p></o:p></p>
<p class="MsoPlainText">/usr/sbin/opensips[19890]: <a href="INFO:core:sig_usr">INFO:core:sig_usr</a>: signal 15 received<o:p></o:p></p>
<p class="MsoPlainText">/usr/sbin/opensips[19889]: <a href="INFO:core:sig_usr">INFO:core:sig_usr</a>: signal 15 received<o:p></o:p></p>
<p class="MsoPlainText">/usr/sbin/opensips[19888]: <a href="INFO:core:sig_usr">INFO:core:sig_usr</a>: signal 15 received<o:p></o:p></p>
<p class="MsoPlainText">/usr/sbin/opensips[19886]: <a href="INFO:core:sig_usr">INFO:core:sig_usr</a>: signal 15 received<o:p></o:p></p>
<p class="MsoPlainText">/usr/sbin/opensips[19885]: <a href="INFO:core:sig_usr">INFO:core:sig_usr</a>: signal 15 received<o:p></o:p></p>
<p class="MsoPlainText">/usr/sbin/opensips[19884]: <a href="INFO:core:sig_usr">INFO:core:sig_usr</a>: signal 15 received<o:p></o:p></p>
<p class="MsoPlainText">/usr/sbin/opensips[19883]: <a href="INFO:core:cleanup">INFO:core:cleanup</a>: cleanup<o:p></o:p></p>
<p class="MsoPlainText">...and so forth.<o:p></o:p></p>
<p class="MsoPlainText"> <o:p></o:p></p>
<p class="MsoPlainText">The process that crashes, 19887 in this particular case, is a listener process. I never see the "Back from xlog" xlog appear. OpenSIPS immediately respawns but I suspect that's systemd.<o:p></o:p></p>
<p class="MsoPlainText"> <o:p></o:p></p>
<p class="MsoPlainText">Am I doing something wrong, or is this a bug?<o:p></o:p></p>
<p class="MsoPlainText"> <o:p></o:p></p>
<p class="MsoPlainText"> <o:p></o:p></p>
<p class="MsoPlainText" style="margin-right:.5in">- Jef<span style="color:#1F497D">f<o:p></o:p></span></p>
</blockquote>
</div>
</body>
</html>