<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:14:04 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[CDRIVER-2068] mongocxx::pool mongos failover</title>
                <link>https://jira.mongodb.org/browse/CDRIVER-2068</link>
                <project id="10030" key="CDRIVER">C Driver</project>
                    <description>&lt;p&gt;We have shard cluster with 3 mongos instances for failover purposes. All mongos in future, will be  distributed on different hosts (now they running on same host with different ports for test purposes).&lt;br/&gt;
The failover needed for backup network channels between client app and mongos. For this purpose, we provide all mongos addreses in mongocxx::uri and then pass it to mongocxx::pool.&lt;br/&gt;
Now, we see so mongocxx::pool does not failover to another mongos if we shutdown first (for example).&lt;br/&gt;
But mongocxx::client does it well (failover to different mongos).&lt;/p&gt;

&lt;p&gt;Does this behaviour is correct or maybe we need to additional setup mongocxx::pool environment for the mongos failover?&lt;/p&gt;</description>
                <environment>Windows 7 x64, Visual Studio 2015</environment>
        <key id="353972">CDRIVER-2068</key>
            <summary>mongocxx::pool mongos failover</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="13202">Works as Designed</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="alm">Aleksander Melnikov</reporter>
                        <labels>
                            <label>driver</label>
                    </labels>
                <created>Wed, 15 Feb 2017 07:49:33 +0000</created>
                <updated>Fri, 27 Oct 2023 13:14:22 +0000</updated>
                            <resolved>Wed, 8 Mar 2017 22:57:55 +0000</resolved>
                                    <version>1.5.2</version>
                                                    <component>network</component>
                                        <votes>0</votes>
                                    <watches>4</watches>
                                                                                                                <comments>
                            <comment id="1519502" author="jesse" created="Wed, 8 Mar 2017 22:57:21 +0000"  >&lt;p&gt;Thanks, here&apos;s what happens:&lt;/p&gt;

&lt;p&gt;1. The C Driver should use all mongos servers equally, but it only uses the first mongos in the seed list due to a recent bug, &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2067&quot; title=&quot;Server selection is not random on Windows&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2067&quot;&gt;&lt;del&gt;CDRIVER-2067&lt;/del&gt;&lt;/a&gt;, which I&apos;ll fix in the next version.&lt;br/&gt;
2. When the first mongos shuts down, you get a series of server errors: the server is refusing to start new operations while it is terminating&lt;br/&gt;
3. Once mongos closes its connection, the C Driver doesn&apos;t detect immediately that the connection is closed, due to &lt;a href=&quot;https://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;a well-known Windows bug&lt;/a&gt;. We&apos;ll investigate a workaround: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2081&quot; title=&quot;Use select() on Windows&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2081&quot;&gt;&lt;del&gt;CDRIVER-2081&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
4. Since the C Driver doesn&apos;t immediately detect the closed connection, it must wait its default socket timeout, which is 5 minutes (we chose a long timeout to allow long-running commands like &quot;createIndexes&quot;). Setting your socket timeout to 10 seconds makes this faster.&lt;br/&gt;
5. Once the socket timeout expires, the C Driver re-checks all the mongos servers in its seed list, in parallel. After its connect timeout (default 10 seconds) expires, it knows that the first mongos is unavailable and the others are available, so it uses the second one. (It will use all available servers equally once &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2067&quot; title=&quot;Server selection is not random on Windows&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2067&quot;&gt;&lt;del&gt;CDRIVER-2067&lt;/del&gt;&lt;/a&gt; is fixed.)&lt;/p&gt;

&lt;p&gt;I&apos;m going to close this bug and continue work in the two related bugs. The mongos failover behavior itself is working as expected on Windows, but there is room for improvement. Thanks for beginning this investigation.&lt;/p&gt;</comment>
                            <comment id="1516396" author="alm" created="Mon, 6 Mar 2017 02:55:38 +0000"  >&lt;p&gt;now, ready to investigate:&lt;br/&gt;
Q: Does the same behavior occur if you shut down the last mongos in the seed list, the one on port 27034, instead?&lt;br/&gt;
A: No, app continue to work.&lt;/p&gt;

&lt;p&gt;Q: If you keep retrying in a loop for 30 seconds or longer, does your application eventually recover and start using the second mongos?&lt;br/&gt;
A: Yes, after bunch of errors, like :&lt;/p&gt;

&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;err: write results unavailable from host:27002 :: caused by :: Location17382: Can&apos;t use connection pool during shutdown: generic server error&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;err: write results unavailable from host:27002 :: caused by :: Location17382: Can&apos;t use connection pool during shutdown: generic server error&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;..... a lot of these messages ...&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;err: write results unavailable from host:27002 :: caused by :: Location17382: Can&apos;t use connection pool during shutdown: generic server error&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;err: Failed to send &quot;insert&quot; command with database &quot;test&quot;: Failure during socket delivery: Unknown error (10054): generic server error&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;err: Failed to connect to target host: 127.0.0.1:27017: generic server error&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;app continue to work.&lt;/p&gt;

&lt;p&gt;Q: How soon after you kill the first mongos do you query the cluster again? Are you in the middle of a query, or do you query within 5 seconds of killing mongos, or more than 5 seconds after?&lt;br/&gt;
A: I query (write to) cluster with 50 ms delay. I attach example code.&lt;/p&gt;

&lt;p&gt;Q: Does this bug manifest if you change your URI to this?:&lt;br/&gt;
A: After change:&lt;/p&gt;

&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;err: write results unavailable from WKS-17364.net.billing.ru:27002 :: caused by :: Location17382: Can&apos;t use connection pool during shutdown: generic server error&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;err: write results unavailable from WKS-17364.net.billing.ru:27002 :: caused by :: Location17382: Can&apos;t use connection pool during shutdown: generic server error&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;err: write results unavailable from WKS-17364.net.billing.ru:27002 :: caused by :: Location17382: Can&apos;t use connection pool during shutdown: generic server error&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;err: could not find host matching read preference { mode: &quot;primary&quot;, tags: [ {} ] } for set mon_0: generic server error&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;err: Failed to send &quot;insert&quot; command with database &quot;test&quot;: socket error or timeout: generic server error&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;err: Failed to connect to target host: 127.0.0.1:27017: generic server error&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;.. then continue to normal work&lt;/p&gt;</comment>
                            <comment id="1515984" author="alm" created="Sat, 4 Mar 2017 01:49:28 +0000"  >&lt;p&gt;I will try to investigate the steps after returning from the vacation March 15&lt;/p&gt;</comment>
                            <comment id="1515528" author="jesse" created="Fri, 3 Mar 2017 18:07:33 +0000"  >&lt;p&gt;Hi Aleksander, have you had an opportunity to try steps 4,5,6,7 to help us diagnose?&lt;/p&gt;</comment>
                            <comment id="1509468" author="alm" created="Sat, 25 Feb 2017 05:21:45 +0000"  >&lt;p&gt;1) MongoDB version 3.4.2&lt;br/&gt;
2) No SSL, no authentication&lt;br/&gt;
3) mongos shut down from trial version of MongoDB Ops Manager (deployment-&amp;gt;processes-&amp;gt;mongos-&amp;gt;shutdown)&lt;br/&gt;
4,5,6,7) will try to investigate ASAP&lt;/p&gt;</comment>
                            <comment id="1507314" author="david.golden" created="Thu, 23 Feb 2017 17:15:55 +0000"  >&lt;p&gt;Aleksander, I&apos;m moving this question to the CDRIVER Jira project, as server monitoring for mongocxx is handled by libmongoc.  Jesse is going to take the lead from here on out and I&apos;ll continue to watch the ticket.&lt;/p&gt;</comment>
                            <comment id="1506759" author="jesse" created="Thu, 23 Feb 2017 03:24:07 +0000"  >&lt;p&gt;Hi, Aleksander.&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;What MongoDB version are you running, please?&lt;/li&gt;
	&lt;li&gt;Do you use SSL and/or authentication?&lt;/li&gt;
	&lt;li&gt;How do you shut down the first mongos?&lt;/li&gt;
	&lt;li&gt;Does the same behavior occur if you shut down the last mongos in the seed list, the one on port 27034, instead?&lt;/li&gt;
	&lt;li&gt;If you keep retrying in a loop for 30 seconds or longer, does your application eventually recover and start using the second mongos?&lt;/li&gt;
	&lt;li&gt;How soon after you kill the first mongos do you query the cluster again? Are you in the middle of a query, or do you query within 5 seconds of killing mongos, or more than 5 seconds after?&lt;/li&gt;
	&lt;li&gt;Does this bug manifest if you change your URI to this?:&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;&quot;mongodb://host:27017,host:27033,host:27034/?socketTimeoutMS=10000&quot;&lt;/p&gt;</comment>
                            <comment id="1505764" author="alm" created="Wed, 22 Feb 2017 04:41:40 +0000"  >&lt;p&gt;1) libmongoc version 1.5.2&lt;br/&gt;
2) uri is &quot;mongodb://host:27017,host:27033,host:27034&quot;&lt;br/&gt;
3) all operations fail (I think all connections in pool fail with one operation)&lt;/p&gt;</comment>
                            <comment id="1505253" author="david.golden" created="Tue, 21 Feb 2017 18:22:33 +0000"  >&lt;p&gt;Hi, Aleksander.  Thanks for the report.&lt;/p&gt;

&lt;p&gt;I have some questions:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;What version of libmongoc are you using?&lt;/li&gt;
	&lt;li&gt;What is the exact URI string you&apos;re using?  (You can omit/change any confidential details)&lt;/li&gt;
	&lt;li&gt;Does a specific operation fail?  Or do all operations fail?&lt;/li&gt;
&lt;/ul&gt;
</comment>
                            <comment id="1499257" author="alm" created="Wed, 15 Feb 2017 10:24:33 +0000"  >&lt;p&gt;while using mongocxx::pool - a lot of exceptions occurs:&lt;br/&gt;
No suitable servers found: `serverSelectionTimeoutMS` expired: &lt;span class=&quot;error&quot;&gt;&amp;#91;connection refused calling ismaster on &amp;#39;host:27017&amp;#39;&amp;#93;&lt;/span&gt; &lt;span class=&quot;error&quot;&gt;&amp;#91;connection refused calling ismaster on &amp;#39;host:27033&amp;#39;&amp;#93;&lt;/span&gt; &lt;span class=&quot;error&quot;&gt;&amp;#91;connection refused calling ismaster on &amp;#39;host:27034&amp;#39;&amp;#93;&lt;/span&gt;: generic server error&lt;/p&gt;

&lt;p&gt;After all - possible all pool entryes used, data continues to be send.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="356449">CDRIVER-2067</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                            <attachment id="150783" name="test.cpp" size="3427" author="alm" created="Mon, 6 Mar 2017 02:57:11 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hsuzbz:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>