<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:15:09 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-2418] mongoc_cmd_parts_assemble() may add readConcern afterClusterTime to generic commands</title>
                <link>https://jira.mongodb.org/browse/CDRIVER-2418</link>
                <project id="10030" key="CDRIVER">C Driver</project>
                    <description>&lt;p&gt;While running something similar to &lt;a href=&quot;https://github.com/mongodb/specifications/blob/master/source/sessions/driver-sessions.rst#test-plan&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;test #2 in the Driver Sessions spec&lt;/a&gt;, I received a server error (&quot;afterClusterTime is not allowed for this command&quot;) on the second of two ping commands sent with the same explicit client session. This was using the generic &lt;tt&gt;mongoc_client_command_with_opts()&lt;/tt&gt; command runner with the &quot;sessionId&quot; option.&lt;/p&gt;

&lt;p&gt;According to the &lt;a href=&quot;https://github.com/mongodb/specifications/blob/master/source/causal-consistency/causal-consistency.rst#causally-consistent-read-commands&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Causal Consistency spec&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The Read and Write Concern Specification states that drivers MUST NOT add a readConcern field to commands that are run using a generic runCommand method. The same is true for causal consistency, so commands that are run using runCommand MUST NOT have an afterClusterTime field added to them.&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;Looking at &lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/blob/1.9.0-rc1/src/mongoc/mongoc-cmd.c#L541&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&lt;tt&gt;mongoc_cmd_parts_assemble()&lt;/tt&gt;&lt;/a&gt;, I believe that we&apos;re entering &lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/blob/1.9.0-rc1/src/mongoc/mongoc-cmd.c#L657&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;this condition&lt;/a&gt;. libmongoc is only checking that the command is not a getMore before deciding to add a read concern with &lt;tt&gt;afterClusterTime&lt;/tt&gt;. I think it may need to track whether the command supports a read concern (similar to &lt;tt&gt;is_write_command&lt;/tt&gt; on &lt;tt&gt;mongoc_cmd_parts_t&lt;/tt&gt;).&lt;/p&gt;</description>
                <environment>MongoDB Enterprise 3.6.0</environment>
        <key id="469063">CDRIVER-2418</key>
            <summary>mongoc_cmd_parts_assemble() may add readConcern afterClusterTime to generic commands</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="jesse@mongodb.com">A. Jesse Jiryu Davis</assignee>
                                    <reporter username="jmikola@mongodb.com">Jeremy Mikola</reporter>
                        <labels>
                    </labels>
                <created>Thu, 7 Dec 2017 00:04:02 +0000</created>
                <updated>Sat, 28 Oct 2023 11:30:15 +0000</updated>
                            <resolved>Fri, 8 Dec 2017 23:47:00 +0000</resolved>
                                                    <fixVersion>1.9.0</fixVersion>
                                    <component>libmongoc</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="1748427" author="xgen-internal-githook" created="Mon, 11 Dec 2017 15:46:37 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;A. Jesse Jiryu Davis&apos;, &apos;email&apos;: &apos;jesse@mongodb.com&apos;, &apos;username&apos;: &apos;ajdavis&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2418&quot; title=&quot;mongoc_cmd_parts_assemble() may add readConcern afterClusterTime to generic commands&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2418&quot;&gt;&lt;del&gt;CDRIVER-2418&lt;/del&gt;&lt;/a&gt; send readConcern only with read cmds&lt;br/&gt;
Branch: r1.9&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/aaee18dc7f7b109291b14e49909a7affc72d48e7&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/aaee18dc7f7b109291b14e49909a7affc72d48e7&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1747551" author="xgen-internal-githook" created="Fri, 8 Dec 2017 23:47:26 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;A. Jesse Jiryu Davis&apos;, &apos;email&apos;: &apos;jesse@mongodb.com&apos;, &apos;username&apos;: &apos;ajdavis&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2418&quot; title=&quot;mongoc_cmd_parts_assemble() may add readConcern afterClusterTime to generic commands&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2418&quot;&gt;&lt;del&gt;CDRIVER-2418&lt;/del&gt;&lt;/a&gt; send readConcern only with read cmds&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/01eece070773f8d9c2f185f74fe8892cb1134e93&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/01eece070773f8d9c2f185f74fe8892cb1134e93&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1745772" author="behackett" created="Thu, 7 Dec 2017 18:42:10 +0000"  >&lt;p&gt;The problem isn&apos;t commands not supporting readConcern. The problem is commands not supporting afterClusterTime. Happily, the commands that don&apos;t support afterClusterTime aren&apos;t on this list:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/mongodb/specifications/blob/master/source/read-write-concern/read-write-concern.rst#read-concern&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/specifications/blob/master/source/read-write-concern/read-write-concern.rst#read-concern&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The upshot is, only certain commands support readConcern (those in the above mentioned list) and only those commands should have afterClusterTime added to them. The command helper shouldn&apos;t be implicitly adding readConcern (though the application should be able to explicitly add one and accept the consequences):&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/mongodb/specifications/blob/master/source/read-write-concern/read-write-concern.rst#generic-command-method&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/specifications/blob/master/source/read-write-concern/read-write-concern.rst#generic-command-method&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fix the readConcern problem and you fix the afterClusterTime problem.&lt;/p&gt;</comment>
                            <comment id="1745355" author="jmikola@gmail.com" created="Thu, 7 Dec 2017 15:00:35 +0000"  >&lt;p&gt;The first option seems preferable, as &lt;tt&gt;mongoc_client_command_with_opts()&lt;/tt&gt; should not be add cluster time per the driver sessions spec. While that function avoids applying defaults from &lt;tt&gt;mongoc_client_t&lt;/tt&gt; (e.g. read concern, write concern), it does respect such options if passed through &lt;tt&gt;opts&lt;/tt&gt;. I suppose even in the case where a user provides a read concern option, we still wouldn&apos;t want to add cluster time to it and just use the read concern option value as-is.&lt;/p&gt;</comment>
                            <comment id="1745317" author="jesse" created="Thu, 7 Dec 2017 14:18:58 +0000"  >&lt;p&gt;Two options.&lt;/p&gt;

&lt;p&gt;1. Decide based on the function you call whether to add readConcern: afterClusterTime. mongoc_client_command_with_opts will not add readConcern: afterClusterTime, whereas mongoc_client_read_command_with_opts, mongoc_client_write_command_with_opts, and mongoc_client_read_write_command_with_opts will add readConcern: afterClusterTime. All the other functions that support sessions &lt;b&gt;will&lt;/b&gt; add readConcern: afterClusterTime. For example, mongoc_collection_aggregate, mongoc_collection_insert_one, etc. etc.&lt;/p&gt;

&lt;p&gt;2. (I hope we can avoid this.) Blacklist known commands that don&apos;t accept readConcern, like &quot;ping&quot; and so on. It doesn&apos;t matter which function you call, only the command name matters.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="471062">CDRIVER-2422</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="407384">PHPC-980</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="469217">DRIVERS-2131</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="447139">SERVER-31613</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <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|htdbs7:</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>