<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:12pt"><div><span>Hello Laura,</span></div><div><span><br></span></div><div>I made a patch with the changes required for a pure DB_ONLY mode.</div><div>You can find it on master branch.</div><div>Any feedback is very welcomed.</div><div><br></div><div>Regards,</div><div>Marius</div><div><br></div><div style="font-size: 12pt; font-family: arial, helvetica, sans-serif; "><div style="font-size: 12pt; font-family: 'times new roman', 'new york', times, serif; "><font size="2" face="Arial"><hr size="1"><b><span style="font-weight:bold;">From:</span></b> laura testi &lt;lau.testi@gmail.com&gt;<br><b><span style="font-weight: bold;">To:</span></b> Henning Westerholt &lt;henning.westerholt@1und1.de&gt;; "Bucur, Marius Ovidiu" &lt;marius.bucur@1and1.ro&gt;<br><b><span style="font-weight: bold;">Cc:</span></b> "sr-users@lists.sip-router.org"
 &lt;sr-users@lists.sip-router.org&gt;<br><b><span style="font-weight: bold;">Sent:</span></b> Thursday, July 21, 2011 11:08 AM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [SR-Users] xcap server - http load–balancer: xcap authentication problem<br></font><br>Hi Marius,<br>thank you for your answer. It would e nice if you can provide a pure<br>DB mode that disable completely subscription hashtable and presentity<br>hashtable in cache but only working with DB. Otherwise it can be still<br>problematic with our test case. Because when the one presence server<br>receives a PUBLISH from one presentity, it will looks-up the local<br>subscription hastable then DB for the active watchers's contact to<br>send notify and update the CSEQ in the subscription hastable/DB.&nbsp; But<br>if there is any subscription of this presentity is in the remote<br>subscription hashtable (another presence server) , the CSEQ of this<br>subscription in hashtable
 will not be updated.<br><br>Thanks!<br><br>Best Regards,<br>Laura<br><br><br>&gt;Hello Laura,<br><br>&gt;Thank you for your email and providing the full test-case.<br>&gt;You are right, there is a certain issue (that is also mentioned in another thread&nbsp; - "DB_ONLY mode in presence module").<br>&gt;The thing is, that there are two caches<br><br> &gt;- a subscription hashtable, maintaining information about active subscripions<br> &gt;- a presentity hashtable, maintaining information about presence<br>entities (presentities, entities that send PUBLISH requests)<br><br>&gt;The db_only mode acts only on the first type of cache - subscriptions.<br>&gt;It really makes sense having the db_only mode act also on the second cache (the presentity cache), hence your usecase is &gt;very common.<br>&gt;There are some cases when you only need a db_only mode only for subscriptions (like when PUBLISH requests are &gt;generated precisely on each presence server
 machines) but of course I think it is a good compromise to disable caching &gt;also for the "presentity" table when running in db_only mode.<br><br>&gt;I will make a patch this evening with this change, and commit it on the master branch.<br>&gt;If anyone has other suggestions, please let me know.<br><br>&gt;Cheers,<br>&gt;Marius<br><br>On Wed, Jul 20, 2011 at 1:11 PM, laura testi &lt;<a ymailto="mailto:lau.testi@gmail.com" href="mailto:lau.testi@gmail.com">lau.testi@gmail.com</a>&gt; wrote:<br>&gt; Hi Marius,<br>&gt; Thank you very much for your explanations. I see your answer only in<br>&gt; the list. Here I copy to here for the convenience:<br>&gt; ----------------------------------------------------------------------------------------------------------------------------------------------------------------------<br>&gt; Hello,<br>&gt;<br>&gt; In the DB_ONLY mode, every SUBSCRIBE request will trigger a database<br>&gt; operation immediately (either
 insert or update).<br>&gt; Also, the SUBSCRIPTION will always be matched from the database.<br>&gt; It behaves exactly as the name implies (write-through).<br>&gt;<br>&gt; If it doesn't then that is a bug. Can you please tell me more about<br>&gt; the scenario you are using?<br>&gt; Is there any usecase in which you can see the subscription in memory<br>&gt; but not in the active_watchers table?<br>&gt;<br>&gt; Regards,<br>&gt; Marius<br>&gt; ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br>&gt;<br>&gt; The scenario wehave tested is like that we have multiple presence<br>&gt; servers and a share DB in the separate DB server. The incoming<br>&gt; SIP/SIMPLE traffic are dispatched with the Dispatcher. The problem we<br>&gt; found is that the write-through mechanism guarantee the<br>&gt; active_watchers cache is synched to DB
 immediately when it change like<br>&gt; your explanation; but not vice versa. For example, when the<br>&gt; active_watchers table in DB is changed by one presence server via the<br>&gt; same write-through mechanism, it seems there is not possible to<br>&gt; populate the changes in DB back to cache of another presence server.<br>&gt; That means the cache in the different presence servers are not<br>&gt; synchronized. It will required complex replications to have cache in<br>&gt; synched.<br>&gt;<br>&gt; I'll try to explain it by the following use case we have tested:<br>&gt; Test Environments:<br>&gt; - SIP clients: (jitsi)<br>&gt; &nbsp; - user1 (has user2 as a contact, user 2 is watcher of user1 with the state=1)<br>&gt; &nbsp; - user2 (has user1 as a contact, user 1 is watcher of user2 withe<br>&gt; the state=1)<br>&gt; - SIP server (kamailio3.1.4)<br>&gt; &nbsp;- 1 x dispatcher (routing based call id)<br>&gt; &nbsp;- 2 x presence servers (PS1 and
 PS2)<br>&gt; - DB server:<br>&gt; &nbsp;- 1 x backend DB server for SIP servers<br>&gt;<br>&gt;<br>&gt; Test Case (user2 is already login and the subscription to user1 is in<br>&gt; one of the 2 PS cache and in DB):<br>&gt; 1) when user1 login, it send SUBSCRIBE presence event of user2 to the<br>&gt; Dispatcher, and Dispatcher forward it to PS1<br>&gt; &nbsp; &nbsp;- PS1 write the subscription (user1-&gt;user2 with CSEQ=1) to<br>&gt; active_watchers cache<br>&gt; &nbsp; &nbsp; &nbsp;then active_wacthers table in DB immediately (write-through)<br>&gt; &nbsp; &nbsp;- PS1 send the NOTIFY of the user2 presence status to user1 and<br>&gt; increase the CSEQ by 1 (becomes 2) to<br>&gt; &nbsp; &nbsp; &nbsp;both cache and DB (write-through)<br>&gt; 2) user1 receive the NOTIFY and check the CSEQ (the first time), and<br>&gt; update the user2's status<br>&gt; 3) user2 change it's presence status and send the PUBLISH to the<br>&gt; dispatcher, and Dispatcher
 forward it to PS2<br>&gt; &nbsp; - PS2 call handle_publish, it look-ups to the local cache for the<br>&gt; active subscription and not found,<br>&gt; &nbsp; &nbsp;then fallback to DB and found it, it increase the CSEQ by 1<br>&gt; (becomes 3 in DB) and send the NOTIFY<br>&gt; &nbsp; &nbsp;to user1 with CSEQ=3 (here is the problem, the CSEQ of the same<br>&gt; subscription in the PS1's cache is still equal 2)<br>&gt; 4) the user1's client receive the NOTIFY and check the CSEQ if it's<br>&gt; greater than the previous one, it's,<br>&gt; &nbsp; &nbsp;then update the Presence Status of user2<br>&gt; 5) user2 change it's presence status again, this time the Dispatcher<br>&gt; forward the PUBLISH to PS1<br>&gt; &nbsp; - PS1 call handle_publish, it look-ups to the local cache for the<br>&gt; active subscription and found it with CSEQ=2!<br>&gt; &nbsp; &nbsp; It increase the CSEQ by 1 (becomes 3 in the cache and update the<br>&gt; value to DB), and send the
 NOTIFY<br>&gt; &nbsp; &nbsp; to user1 with CSEQ=3 again.<br>&gt; 6) user1's client receive the NOTIFY and check the CSEQ if it's<br>&gt; greater than the previous one, it's not,<br>&gt; &nbsp; then it ignore it, the presen status of user2 is not updated in the<br>&gt; user1's client!<br>&gt;<br>&gt;<br>&gt; This problem can be solved if we have pure DB mode only. In that case,<br>&gt; the CSEQ is always increased for the successive NOTIFY of the same<br>&gt; subscription.<br>&gt;<br>&gt;<br>&gt; It would be nice &nbsp;to keep the new Write-Through DB Mode in the<br>&gt; presence module, and add a Pure DB mode, just like the usrloc module?<br>&gt;<br>&gt; Just in case, in usrloc module, it miss the fallback to DB mode but<br>&gt; has write-through and pure db mode ;-)<br>&gt;<br>&gt; Best Regards,<br>&gt; Laura<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt; On Fri, Jul 15, 2011 at 4:58 PM, Henning Westerholt<br>&gt;
 &lt;<a ymailto="mailto:henning.westerholt@1und1.de" href="mailto:henning.westerholt@1und1.de">henning.westerholt@1und1.de</a>&gt; wrote:<br>&gt;&gt;<br>&gt;&gt; On Friday 15 July 2011, laura testi wrote:<br>&gt;&gt; &gt; we have checked the presence extension for DB_MODE only in the master<br>&gt;&gt; &gt; branch. But it's not complete DB_ONLY mode, it seems that it still uses<br>&gt;&gt; &gt; the cache for active_watchers in write through mode. Is there any reason<br>&gt;&gt; &gt; for it? That can still make problem for the scalability for the multiple<br>&gt;&gt; &gt; presence servers, because if an presence event (either SIP or XCAP) of an<br>&gt;&gt; &gt; active subscription in the cache of one presence server, goes to another<br>&gt;&gt; &gt; presence server, can still cause the problem even the DB is sync with the<br>&gt;&gt; &gt; cache.<br>&gt;&gt;<br>&gt;&gt; Hello Marius,<br>&gt;&gt;<br>&gt;&gt; maybe you can comment a bit on
 this?<br>&gt;&gt;<br>&gt;&gt; Thanks and best regards,<br>&gt;&gt;<br>&gt;&gt; Henning<br>&gt;<br><br>_______________________________________________<br>SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br><a ymailto="mailto:sr-users@lists.sip-router.org" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br><a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br><br><br></div></div></div></body></html>