<div dir="ltr">What exactly do I have?<div><br></div><div>I have a global cluster of DocumentDB (AWS service ) which is mongodb compatible . </div><div><br></div><div>In the global cluster , the primary cluster is in us-east and the secondary cluster is in us-west . </div><div><br></div><div>I have 2 connection strings for both clusters , <a href="http://primary.xyz.com" target="_blank">primary.xyz.com</a> pointed to primary cluster , <a href="http://secondary.xyz.com" target="_blank">secondary.xyz.com</a> pointed to secondary cluster (secondary cluster only has read replicas) . </div><div><br></div><div>In opensips I have given both the domains like below . </div><div><br></div><div>modparam("usrloc", "cachedb_url","mongodb//docdb:cccl0g1c@<b><a href="http://primary.xyz.com:27017" target="_blank">primary.xyz.com:27017</a></b>,<b><a href="http://secondary.xyz.com:27017" target="_blank">secondary.xyz.com:27017</a></b>/opensipsDB.userlocation?&readPreference=secondaryPreferred&retryWrites=false")<br></div><div><br></div><div>whenever my primary cluster goes down and secondary is promoted to primary , opensips throws an error of connection loss . Opensips at that point also trying to connect to the <b><a href="http://primary.xyz.com">primary.xyz.com</a> </b>although that is down<b> . </b></div><div><b><br></b></div><div><b>At this point , my expectation was , opensips must have automatically detect the the older primary cluster was down and secondary was became primary and work properly . </b></div><div><b><br></b></div><div><b>But its not happening . Once I restart the service its works fine . </b></div><div><br></div><div><br></div><div><br></div><div><br><div><br></div><div><br clear="all"><div><div dir="ltr" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><b><i>Thanks & Regards</i></b><div><i>Sasmita Panda</i></div><div><i>Senior Network Testing and Software Engineer</i></div><div><i>3CLogic , ph:07827611765</i></div></div></div></div></div></div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Aug 24, 2022 at 3:30 PM Liviu Chircu <<a href="mailto:liviu@opensips.org" target="_blank">liviu@opensips.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<div>On 24.08.2022 11:56, Sasmita Panda
wrote:<br>
</div>
<blockquote type="cite">
<div><br>
</div>
<div>Now my primary cluster goes down so my secondary cluster
becomes primary . I have updated the connection string
against the domain in route53 . Now </div>
<div><b><a href="http://primary-cluster.xzy.com" target="_blank">primary-cluster.xzy.com</a></b> is
pointed to the new primary custer connection string . </div>
<div><br>
</div>
<div>While creating a connection from the console through the
mongo shell it's getting connected . But opensips is not able to
switch the connecting string somehow . still it's trying to
connect to the previous primary connection string . </div>
<div><br>
</div>
<div>It seems like opensips has cached the connection string and
is trying to connect to the same even after I have updated the
string from the backend . </div>
</blockquote>
<p><font face="monospace">libmongo will try each node in your CSV of
nodes, there is no going around this. Now, while your usage of
two completely different clusters in the same connection string
seems to be <b>non-conventional</b> (I don't recall any
documentation advising this, all Mongo docs talk about
connecting to either a <b>replica set</b>, or to a <b>list of</b>
<b>mongos</b> servers), I still think it could work. Maybe just
configure the "connectionTimeousMS" parameters (or others??) and
see if you can get libmongoc to time out faster on your 1st
cluster, when it goes down.</font></p>
<p><font face="monospace">Best regards,</font><br>
</p>
<pre cols="72">--
Liviu Chircu
<a href="http://www.twitter.com/liviuchircu" target="_blank">www.twitter.com/liviuchircu</a> | <a href="http://www.opensips-solutions.com" target="_blank">www.opensips-solutions.com</a>
OpenSIPS Summit 2022 Athens, Sep 27-30 | <a href="http://www.opensips.org/events" target="_blank">www.opensips.org/events</a></pre>
</div>
</blockquote></div>