<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:36:51 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>[GODRIVER-1658] connections should update topology faster for failed handshakes</title>
                <link>https://jira.mongodb.org/browse/GODRIVER-1658</link>
                <project id="14289" key="GODRIVER">Go Driver</project>
                    <description>&lt;p&gt;&lt;b&gt;Updated Description&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;We should change two aspects of updating the topology for connection handshakes:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;Successful handshakes should not update the topology. This can be done by removing the &lt;tt&gt;withServerDescriptionCallback&lt;/tt&gt; connection option. Having this functionality is actually harmful unless we also have the connection handshakes update the average RTT because it causes our RTT calculations to go askew. Also, it causes unnecessary lock contention because the description for each new connection handshake needs to be applied.&lt;/li&gt;
	&lt;li&gt;Failed handshakes should update the topology more quickly. Currently, SDAM error handling for handshakes is done in &lt;tt&gt;Server.Connection&lt;/tt&gt;. This should be done in &lt;tt&gt;connection.connect&lt;/tt&gt; rather than waiting for the connection to be checked out because the error could be stale by that time.&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;&lt;b&gt;Original Description&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;We have a few replsets that are configured to span multiple regions (A and B, about 100ms apart).&#160; Even though we&apos;re using the latency read preference selector with a threshold of 0ms (i.e. select the closest node), we regularly observe requests from region A being routed to nodes in region B.&#160; After adding some debug logging, I&apos;ve noticed that AverageRTT is regularly reset.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;I believe what&apos;s happening is that when a new connection to the server is needed, &quot;connect&quot; is called in&#160;topology/connection.go.&#160; That calls &quot;c.desc, err = handshaker.GetDescription(ctx, c.addr, handshakeConn)&quot;, and then &quot;c.config.descCallback(c.desc)&quot;.&#160; That callback is setup in &quot;NewServer&quot;, via &quot;s.pool, err = newPool(pc, withServerDescriptionCallback(callback, cfg.connectionOpts...)...)&quot;, with &quot;callback := func(desc description.Server) { s.updateDescription(desc, false) }&quot;.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;&quot;updateDescription&quot; calls into &quot;updateTopologyCallback&quot;, which is set in &quot;Connect&quot; and &quot;ConnectServer&quot;, which calls &quot;t.apply(context.TODO(), desc)&quot;.&#160; This then applies the update to the topology itself.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;Unwinding, the issue is that the description returned by &quot;handshaker.GetDescription&quot; does not have AverageRTT set.&#160; That implementation just calls &quot;NewMaster(...).GetDescription()&quot;, which calls &quot;IsMaster.Result(...)&quot;, and that does not set AverageRTT.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;It seems like the fix should be to preserve AverageRTT in most cases, possibly in &quot;replaceServer&quot; or &quot;updateDescription&quot;.&#160; It&apos;s possible there are other fields in &quot;description.Server&quot; that should be preserved; as a start, it might make sense to reorder fields into &quot;things copied from the result of isMaster&quot;, like&#160;Compression and&#160;WireVersion, and things updated out of band, like&#160;AverageRTT.&lt;/p&gt;</description>
                <environment></environment>
        <key id="1383370">GODRIVER-1658</key>
            <summary>connections should update topology faster for failed handshakes</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</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="13201">Fixed</resolution>
                                        <assignee username="divjot.arora@mongodb.com">Divjot Arora</assignee>
                                    <reporter username="bartle">David Bartley</reporter>
                        <labels>
                    </labels>
                <created>Thu, 18 Jun 2020 03:39:28 +0000</created>
                <updated>Sat, 28 Oct 2023 11:38:08 +0000</updated>
                            <resolved>Mon, 29 Jun 2020 21:10:10 +0000</resolved>
                                                    <fixVersion>1.3.5</fixVersion>
                                    <component>Server Discovery and Monitoring</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="3230062" author="divjot.arora" created="Tue, 30 Jun 2020 14:20:30 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=bartle&quot; class=&quot;user-hover&quot; rel=&quot;bartle&quot;&gt;bartle&lt;/a&gt;&#160;The planned release date for 1.3.5 is early next week. We generally do patch releases on a monthly cadence.&lt;/p&gt;</comment>
                            <comment id="3229253" author="bartle" created="Mon, 29 Jun 2020 23:21:31 +0000"  >&lt;p&gt;ooc when do you plan to release 1.3.5?&lt;/p&gt;</comment>
                            <comment id="3224013" author="xgen-internal-githook" created="Thu, 25 Jun 2020 15:25:11 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Divjot Arora&apos;, &apos;email&apos;: &apos;divjot.arora@10gen.com&apos;, &apos;username&apos;: &apos;divjotarora&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-1658&quot; title=&quot;connections should update topology faster for failed handshakes&quot; class=&quot;issue-link&quot; data-issue-key=&quot;GODRIVER-1658&quot;&gt;&lt;del&gt;GODRIVER-1658&lt;/del&gt;&lt;/a&gt; Remove extraneous go.mod addition in backport&lt;br/&gt;
Branch: release/1.3&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-go-driver/commit/6b450cf6e88d8a7e656c91751ae9c980f3a310bd&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-go-driver/commit/6b450cf6e88d8a7e656c91751ae9c980f3a310bd&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="3224011" author="xgen-internal-githook" created="Thu, 25 Jun 2020 15:23:23 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Divjot Arora&apos;, &apos;email&apos;: &apos;divjot.arora@10gen.com&apos;, &apos;username&apos;: &apos;divjotarora&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-1658&quot; title=&quot;connections should update topology faster for failed handshakes&quot; class=&quot;issue-link&quot; data-issue-key=&quot;GODRIVER-1658&quot;&gt;&lt;del&gt;GODRIVER-1658&lt;/del&gt;&lt;/a&gt; Fix connection updates to topology (#429)&lt;br/&gt;
Branch: release/1.3&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-go-driver/commit/0eb881e680a929d592d6d1c5a2cd93f3f03c89e9&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-go-driver/commit/0eb881e680a929d592d6d1c5a2cd93f3f03c89e9&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="3223984" author="xgen-internal-githook" created="Thu, 25 Jun 2020 15:09:26 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Divjot Arora&apos;, &apos;email&apos;: &apos;divjot.arora@10gen.com&apos;, &apos;username&apos;: &apos;divjotarora&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-1658&quot; title=&quot;connections should update topology faster for failed handshakes&quot; class=&quot;issue-link&quot; data-issue-key=&quot;GODRIVER-1658&quot;&gt;&lt;del&gt;GODRIVER-1658&lt;/del&gt;&lt;/a&gt; Fix connection updates to topology (#429)&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-go-driver/commit/34d063f327ed6d3c01cc2aa4c55b0c075d61f8a0&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-go-driver/commit/34d063f327ed6d3c01cc2aa4c55b0c075d61f8a0&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="3217989" author="divjot.arora" created="Mon, 22 Jun 2020 17:42:50 +0000"  >&lt;p&gt;&lt;a href=&quot;https://github.com/mongodb/mongo-go-driver/pull/429&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-go-driver/pull/429&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="3215146" author="divjot.arora" created="Thu, 18 Jun 2020 21:11:00 +0000"  >&lt;p&gt;We should make two fixes for this ticket:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;Remove the functionality to update the topology during successful handshakes.&lt;/li&gt;
	&lt;li&gt;Fix how we update the topology for failed handshakes. Currently, we implement the &quot;before handshake completes&quot; part of SDAM error handling (&lt;a href=&quot;https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring.rst#network-error-when-reading-or-writing&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring.rst#network-error-when-reading-or-writing&lt;/a&gt;) in the &lt;tt&gt;Server.Connection&lt;/tt&gt; method. However, if we encounter an error while creating connections for the MinPoolSize maintenance routine, we won&apos;t handle that error until the connection is actually checked out. We should fix this by having connection.connect pass the handshaking error to the associated Server.&lt;/li&gt;
&lt;/ol&gt;
</comment>
                            <comment id="3214721" author="divjot.arora" created="Thu, 18 Jun 2020 18:00:21 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=bartle&quot; class=&quot;user-hover&quot; rel=&quot;bartle&quot;&gt;bartle&lt;/a&gt;&#160;I think that is the correct fix. The server discovery and monitoring specification says that drivers should use isMaster replies from application connection handshakes to update the topology, but most drivers don&apos;t do this because there&apos;s little gain. I was planning on removing this functionality anyway as part of &lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-1489&quot; title=&quot;Reduce Client Time To Recovery On Topology Changes&quot; class=&quot;issue-link&quot; data-issue-key=&quot;GODRIVER-1489&quot;&gt;&lt;del&gt;GODRIVER-1489&lt;/del&gt;&lt;/a&gt; and DRIVERS-1300 has been created to amend the specification as well. Because it&apos;s actually causing a bug, I&apos;ll do this and cherry-pick to the 1.3.x branch so it can go into the 1.3.5 release as well.&lt;/p&gt;</comment>
                            <comment id="3214513" author="bartle" created="Thu, 18 Jun 2020 16:38:48 +0000"  >&lt;p&gt;I made a small change to remove the call to &quot;withServerDescriptionCallback&quot; and verified that almost no queries are being routed to the non-local region (I&apos;m not sure that&apos;s the correct fix, I just wanted to validate my hypothesis).&lt;/p&gt;</comment>
                            <comment id="3213597" author="bartle" created="Thu, 18 Jun 2020 06:01:01 +0000"  >&lt;p&gt;Forgot to mention this was on version&#160;1.3.3 of the driver.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </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|hr513j:</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>