<p>Hi <a class="user-mention" data-hovercard-user-id="3033729" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/charlesrchance">@charlesrchance</a>, thanks for the time to look into this.</p>
<p>What you say totally matches the "weird" behaviors I was seeing. You really gave me a lot of clarity understanding what is going on behind the scenes.</p>
<p>To answer your questions:</p>
<ol>
<li>
<p>Yes, I have database but my idea was to move away from it for each thing I handle using DMQ. This also matches chronology of events, I have been restarting nodes here and there, I wasn't "losing" dialogs, but making them "orphaned" instead without knowing.</p>
</li>
<li>
<p>So there are (at least) a couple different options here:<br>
2a) stat counters would have all dialogs (local + replicated), which in reality is the true value, as from kamailio's perspective, those dialogs are there and they are active aren't they?<br>
2b) stat counters would only have local dialogs, so if you want to have full dialog count you would have to stack the values from all nodes.</p>
</li>
</ol>
<p>Now there is also a <code>dlg.stats_active</code> that gives you current dialogs (not sure if it also shows replicated ones)  so maybe we can benefit from both options, a counter that includes both local and replicated dialogs, and a different counter (dlg.stats_active?) that has only the current-local-count of dialogs.</p>
<p>Since I fully restarted both SBCs (which in fact, that was clearing the orphaned dialogs) I haven't seen a spike (negative counter).</p>
<p>At this point I don't know what the best options is, I do understand perfectly the problem though.</p>
<p><a class="user-mention" data-hovercard-user-id="184809" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/miconda">@miconda</a> what do you think about all this?</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/1591#issuecomment-409303111">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AF36ZYZW1jxVwM2oPUcvyBXL4OVXblELks5uMJQwgaJpZM4VLmd9">mute the thread</a>.<img src="https://github.com/notifications/beacon/AF36ZQh56RXuBGWWAbSm4EMpZkZRlkE1ks5uMJQwgaJpZM4VLmd9.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/kamailio/kamailio","title":"kamailio/kamailio","subtitle":"GitHub repository","main_image_url":"https://assets-cdn.github.com/images/email/message_cards/header.png","avatar_image_url":"https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/kamailio/kamailio"}},"updates":{"snippets":[{"icon":"PERSON","message":"@joelsdc in #1591: Hi @charlesrchance, thanks for the time to look into this.\r\n\r\nWhat you say totally matches the \"weird\" behaviors I was seeing. You really gave me a lot of clarity understanding what is going on behind the scenes.\r\n\r\nTo answer your questions:\r\n\r\n1. Yes, I have database but my idea was to move away from it for each thing I handle using DMQ. This also matches chronology of events, I have been restarting nodes here and there, I wasn't \"losing\" dialogs, but making them \"orphaned\" instead without knowing.\r\n\r\n2. So there are (at least) a couple different options here:\r\n2a) stat counters would have all dialogs (local + replicated), which in reality is the true value, as from kamailio's perspective, those dialogs are there and they are active aren't they?\r\n2b) stat counters would only have local dialogs, so if you want to have full dialog count you would have to stack the values from all nodes.\r\n\r\nNow there is also a `dlg.stats_active` that gives you current dialogs (not sure if it also shows replicated ones)  so maybe we can benefit from both options, a counter that includes both local and replicated dialogs, and a different counter (dlg.stats_active?) that has only the current-local-count of dialogs.\r\n\r\nSince I fully restarted both SBCs (which in fact, that was clearing the orphaned dialogs) I haven't seen a spike (negative counter).\r\n\r\nAt this point I don't know what the best options is, I do understand perfectly the problem though.\r\n\r\n@miconda what do you think about all this?\r\n\r\n\r\n\r\n\r\n\r\n"}],"action":{"name":"View Issue","url":"https://github.com/kamailio/kamailio/issues/1591#issuecomment-409303111"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/issues/1591#issuecomment-409303111",
"url": "https://github.com/kamailio/kamailio/issues/1591#issuecomment-409303111",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
},
{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"hideOriginalBody": "false",
"originator": "AF6C5A86-E920-430C-9C59-A73278B5EFEB",
"title": "Re: [kamailio/kamailio] RPC command stats.get_statistics randomly reporting 9223372036854776000 for current active/early dialogs (#1591)",
"sections": [
{
"text": "",
"activityTitle": "**Joel Serrano**",
"activityImage": "https://assets-cdn.github.com/images/email/message_cards/avatar.png",
"activitySubtitle": "@joelsdc",
"facts": [

]
}
],
"potentialAction": [
{
"name": "Add a comment",
"@type": "ActionCard",
"inputs": [
{
"isMultiLine": true,
"@type": "TextInput",
"id": "IssueComment",
"isRequired": false
}
],
"actions": [
{
"name": "Comment",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"IssueComment\",\n\"repositoryFullName\": \"kamailio/kamailio\",\n\"issueId\": 1591,\n\"IssueComment\": \"{{IssueComment.value}}\"\n}"
}
]
},
{
"name": "Close issue",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"IssueClose\",\n\"repositoryFullName\": \"kamailio/kamailio\",\n\"issueId\": 1591\n}"
},
{
"targets": [
{
"os": "default",
"uri": "https://github.com/kamailio/kamailio/issues/1591#issuecomment-409303111"
}
],
"@type": "OpenUri",
"name": "View on GitHub"
},
{
"name": "Unsubscribe",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\": 355362685\n}"
}
],
"themeColor": "26292E"
}
]</script>