<div dir="ltr">Hi Liviu , <div><br></div><div>I have mapped a domain in AWS route53 <a href="http://primary-clsuter.xyz.com">primary-clsuter.xyz.com</a> to mongodb primary cluster connection string  . </div><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">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><div><br></div><div>Once I restart the opensips service everything starts working and the connection string was updated to the latest primary cluster connection string . </div><div><br></div><div><br></div><div>How will I manage this ?</div><div><br></div><div><br clear="all"><div><div dir="ltr" class="gmail_signature" 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><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Aug 23, 2022 at 3:31 PM Liviu Chircu <<a href="mailto:liviu@opensips.org">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">On 22.08.2022 08:44, Sasmita Panda wrote:<br>
><br>
> When I am configuring 2 connectionstrings here , that means<br>
> 1. Opensips will always honor the 1st one as primary and 2nd one as <br>
> secondary ?<br>
><br>
> 2. If the 1st one will get down and 2nd one becomes primary , what <br>
> will happen to opensips ? Will that keep the 2nd one as primary <br>
> automatically or I have to switch the domain in the config ?<br>
><br>
> 3. How does opensips decide which one is primary and which is secondary ?<br>
><br>
> Please help me out . I am stuck in the middle of something here .<br>
<br>
Hi Sasmita,<br>
<br>
This has more to do with the libmongoc library behavior, rather than <br>
OpenSIPS.  First, the multi-host replica set syntax is part of the <br>
MongoDB connection string syntax[1], so everything that you can read on <br>
the Mongo website also applies to the "cachedb_mongodb" module.<br>
<br>
1. This means that once you include the "replicaSet=rs0" component, the <br>
library will automatically establish who is the PRIMARY node on each <br>
query.  If the PRIMARY should ever change (either due to system failure, <br>
manual switch, etc.), the library will be able to switch to the new <br>
PRIMARY, whichever that may become (imagine you have a 5-node replica set).<br>
<br>
2. no need to change the config string. The library will always know <br>
which is the PRIMARY (writer) node.<br>
<br>
3. I cannot say... I image the library will connect to each node and run <br>
an "isMaster()"[2] command?  I suggest you do an ngrep or even a PCAP <br>
capture - that should give you more info on libmongoc behavior.<br>
<br>
[1]: <a href="https://www.mongodb.com/docs/v5.2/reference/connection-string/" rel="noreferrer" target="_blank">https://www.mongodb.com/docs/v5.2/reference/connection-string/</a><br>
[2]: <a href="https://www.mongodb.com/docs/v4.2/reference/command/isMaster/" rel="noreferrer" target="_blank">https://www.mongodb.com/docs/v4.2/reference/command/isMaster/</a><br>
<br>
Best regards,<br>
<br>
-- <br>
Liviu Chircu<br>
<a href="http://www.twitter.com/liviuchircu" rel="noreferrer" target="_blank">www.twitter.com/liviuchircu</a> | <a href="http://www.opensips-solutions.com" rel="noreferrer" target="_blank">www.opensips-solutions.com</a><br>
OpenSIPS Summit 2022 Athens, Sep 27-30 | <a href="http://www.opensips.org/events" rel="noreferrer" target="_blank">www.opensips.org/events</a><br>
<br>
</blockquote></div>