<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:19:33 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-3971] Error if appending an &quot;lsid&quot; field would introduce a duplicate field</title>
                <link>https://jira.mongodb.org/browse/CDRIVER-3971</link>
                <project id="10030" key="CDRIVER">C Driver</project>
                    <description>&lt;p&gt;Assuming an &quot;lsid&quot; field is not prohibited by the command, &lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/blob/1.17.5/src/libmongoc/src/mongoc/mongoc-cmd.c#L809&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; will use &lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/blob/1.17.5/src/libmongoc/src/mongoc/mongoc-cmd.c#L931&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&lt;tt&gt;bson_append_document&lt;/tt&gt;&lt;/a&gt; to append an &quot;lsid&quot; field to a command document. In the unlikely event that the command document already has an &quot;lsid&quot; field, this will result in duplicate BSON fields in the outgoing command.&lt;/p&gt;

&lt;p&gt;In turn, this can be difficult to diagnose during debugging. Consider the following scenario in PHP, where an &quot;lsid&quot; string field as manually added to a &quot;findAndModify&quot; command:&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;findAndModify command:&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;{&quot;findAndModify&quot;:&quot;test&quot;,&quot;query&quot;:{&quot;AAA&quot;:1},&quot;update&quot;:{&quot;$inc&quot;:{&quot;AAA&quot;:1}},&quot;upsert&quot;:true,&quot;new&quot;:true,&quot;txnNumber&quot;:1,&quot;lsid&quot;:{&quot;id&quot;:{&quot;$binary&quot;:&quot;gUD36a8WS+Sxxs2\/0122IQ==&quot;,&quot;$type&quot;:&quot;04&quot;}},&quot;$db&quot;:&quot;test&quot;,&quot;$clusterTime&quot;:{&quot;clusterTime&quot;:{&quot;$timestamp&quot;:{&quot;t&quot;:1619799291,&quot;i&quot;:1}},&quot;signature&quot;:{&quot;hash&quot;:{&quot;$binary&quot;:&quot;AAAAAAAAAAAAAAAAAAAAAAAAAAA=&quot;,&quot;$type&quot;:&quot;00&quot;},&quot;keyId&quot;:0}}}&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;&amp;nbsp;&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;&amp;nbsp;&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;Fatal error: Uncaught MongoDB\Driver\Exception\CommandException: BSON field &apos;OperationSessionInfo.lsid&apos; is the wrong type &apos;string&apos;, expected type &apos;object&apos;&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;APM was used to log outgoing commands as JSON; however, the BSON document is first decoded into a PHP object before being provided to the APM callback. In that case, the last &quot;lsid&quot; field in the document wins.&lt;/p&gt;

&lt;p&gt;I don&apos;t think this would be as difficult to debug in libmongoc, since libbson&apos;s visitors (used to encode Extended JSON) would still visit both keys. In that case, we might expect to see both &quot;lsid&quot; fields in dumped JSON. For raw BSON iteration (e.g. &lt;tt&gt;bson_iter_find&lt;/tt&gt;), I expect the first field in the document would be returned. In that case, debugging might only report the original &quot;lsid&quot; field from the user.&lt;/p&gt;

&lt;p&gt;In this example, I was purposely using an invalid &quot;lsid&quot; type to coerce an exception; however, another edge case would be providing a valid &quot;lsid&quot; in the command. In that case, libmongoc would still append its own &quot;lsid&quot; field. Presumably, the server would utilize the first &quot;lsid&quot; and ignore the second. This might satisfy the user&apos;s original intention since libmongoc&apos;s appended &quot;lsid&quot; would be ignored; however, libmongoc might go on to update the session that wasn&apos;t actually used for the operation (e.g. last used time).&lt;/p&gt;

&lt;p&gt;FYI: the &lt;a href=&quot;https://github.com/mongodb/specifications/blob/master/source/transactions/transactions.rst#what-happens-when-a-command-object-passed-to-runcommand-already-contains-a-transaction-field-eg-lsid-txnnumber-etc&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Driver Sessions spec&lt;/a&gt; advises applications not to do this and suggests that behavior is undefined.&lt;/p&gt;</description>
                <environment></environment>
        <key id="1697714">CDRIVER-3971</key>
            <summary>Error if appending an &quot;lsid&quot; field would introduce a duplicate field</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="10300" iconUrl="https://jira.mongodb.org/images/icons/priorities/medium.svg">Unknown</priority>
                        <status id="10038" iconUrl="https://jira.mongodb.org/images/icons/subtask.gif" description="">Backlog</status>
                    <statusCategory id="2" key="new" colorName="default"/>
                                    <resolution id="-1">Unresolved</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="jmikola@mongodb.com">Jeremy Mikola</reporter>
                        <labels>
                    </labels>
                <created>Fri, 30 Apr 2021 16:41:47 +0000</created>
                <updated>Thu, 31 Mar 2022 13:36:40 +0000</updated>
                                                                            <component>libmongoc</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                    <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="1681575">CDRIVER-3978</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|hysk8n:</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>