<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;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Calibri",sans-serif;}
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;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@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 lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt">Hello,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">We are seeing some failures that appear to be caused by the Statistics module not operating properly for concurrent execution. When a particular statistic is updated nearly simultaneously by multiple OpenSIPS
 threads, the statistic does not end up with the correct value; some of the updates appear to get overwritten.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">The following log is output when the statistic “calls:Response|481” is updated simultaneously by 2 different threads. Each update is “+1”, but at the end of this execution the value of the statistic was queried
 and found to be only 1.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Apr 25 14:12:05 [323] DBG:tm:t_check: start=0x7fe936057450<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Apr 25 14:12:05 [322] DBG:tm:t_check: start=0x7fe93605a570<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Apr 25 14:12:05 [323] DBG:tm:t_check: transaction already found!<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Apr 25 14:12:05 [322] DBG:tm:t_check: transaction already found!<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Apr 25 14:12:05 [323] DBG:tm:pv_get_tm_reply_code: reply code is <481><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Apr 25 14:12:05 [322] DBG:tm:pv_get_tm_reply_code: reply code is <481><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Apr 25 14:12:05 [323] DBG:core:comp_scriptvar: int 20 : 5 / 0<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Apr 25 14:12:05 [322] DBG:core:comp_scriptvar: int 20 : 5 / 0<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Apr 25 14:12:05 [322] DBG:core:comp_scriptvar: str 20 : calls<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Apr 25 14:12:05 [323] DBG:core:comp_scriptvar: str 20 : calls<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Apr 25 14:12:05 [322] DBG:core:comp_scriptvar: int 20 : 12 / 0<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Apr 25 14:12:05 [323] DBG:core:comp_scriptvar: int 20 : 12 / 0<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Apr 25 14:12:05 [322] DBG:core:comp_scriptvar: str 20 : Response|481<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Apr 25 14:12:05 [323] DBG:core:comp_scriptvar: str 20 : Response|481<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Apr 25 14:12:05 [322] DBG:statistics:w_update_stat: needed statistic is <calls:Response|481><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Apr 25 14:12:05 [323] DBG:statistics:w_update_stat: needed statistic is <calls:Response|481><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Apr 25 14:12:05 [323] DBG:statistics:parse_groupname: group: 'calls', name: 'Response|481'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Apr 25 14:12:05 [322] DBG:statistics:parse_groupname: group: 'calls', name: 'Response|481'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Apr 25 14:12:05 [322] DBG:statistics:w_update_stat: creating statistic <calls:Response|481><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Apr 25 14:12:05 [323] DBG:statistics:w_update_stat: creating statistic <calls:Response|481><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Apr 25 14:12:05 [322] DBG:tm:relay_reply: T_state=4, branch=0, save=0, relay=0, cancel_BM=0<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Apr 25 14:12:05 [323] DBG:tm:relay_reply: T_state=4, branch=0, save=0, relay=0, cancel_BM=0<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">It this intended? I know the cfg_utils module contains some functionality for script-level locking that could potentially help here, but it seems like the statistics module should internally prevent this sort
 of data consistency error.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:black">Ben Newlin </span>
<o:p></o:p></p>
</div>
</body>
</html>