<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 05:39:40 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>[SERVER-56592] Unexpected results when different commands share the same lsid and txnNumber</title>
                <link>https://jira.mongodb.org/browse/SERVER-56592</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-3978&quot; title=&quot;Add entropy for OpenSSL RAND_bytes to avoid duplicate sequences for same PID&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-3978&quot;&gt;&lt;del&gt;SERVER-56137&lt;/del&gt;&lt;/a&gt; presented a case where an application was sending many &lt;tt&gt;findAndModify&lt;/tt&gt; commands from forked child processes. Each command had different query/update options, but thansk to an &lt;a href=&quot;https://wiki.openssl.org/index.php/Random_fork-safety&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;old OpenSSL bug&lt;/a&gt; some of the commands ended up using the same combination of &lt;tt&gt;lsid&lt;/tt&gt; and &lt;tt&gt;txnNumber&lt;/tt&gt; fields. This lead to an interesting, albeit expected, interaction with retryable writes whereby the server would the result of the first &lt;tt&gt;findAndModify&lt;/tt&gt; operation to use that &lt;tt&gt;lsid&lt;/tt&gt;/&lt;tt&gt;txnNumber&lt;/tt&gt; combination for the subsequent &lt;tt&gt;findAndModify&lt;/tt&gt; that re-used the combination.&lt;/p&gt;

&lt;h3&gt;&lt;a name=&quot;Observingdifferentcommandsthatresembleretryattempts&quot;&gt;&lt;/a&gt;Observing different commands that resemble retry attempts&lt;/h3&gt;

&lt;p&gt;While investigating that issue, I also looked into what would happen if the subsequent command sharing the same &lt;tt&gt;lsid&lt;/tt&gt;/&lt;tt&gt;txnNumber&lt;/tt&gt; was &lt;em&gt;not&lt;/em&gt; a &lt;tt&gt;findAndModify&lt;/tt&gt;. Additionally, what if some commands were bulk writes that had multiple statements for the same &lt;tt&gt;txnNumber&lt;/tt&gt;? This lead to some surprising discoveries in how the server crafts its responses for retryable writes. Since I&apos;m familiar with retryable writes (e.g. &quot;at-most-once&quot; semantics, reliance on the oplog), these results below are not completely unexpected; however, they would likely be very confusing for a user.&lt;/p&gt;

&lt;p&gt;Consider the following sequence of commands/replies observed between a driver (intentionally using fixed &lt;tt&gt;lsid&lt;/tt&gt;/&lt;tt&gt;txnNumber&lt;/tt&gt; combinations) and a MongoDB 4.4 primary:&lt;/p&gt;

&lt;h4&gt;&lt;a name=&quot;Oneinsert&quot;&gt;&lt;/a&gt;One insert&lt;/h4&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;insert 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;insert&quot;:&quot;test&quot;,&quot;documents&quot;:[{&quot;AAA&quot;:1}],&quot;txnNumber&quot;:1,&quot;$db&quot;:&quot;test&quot;,&quot;lsid&quot;:{&quot;id&quot;:{&quot;$binary&quot;:&quot;YXt1nbJBTWmgNPM+Vjug2A==&quot;,&quot;$type&quot;:&quot;04&quot;}},&quot;$clusterTime&quot;:{&quot;clusterTime&quot;:{&quot;$timestamp&quot;:{&quot;t&quot;:1620079815,&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;&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;insert reply:&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;n&quot;:1,&quot;opTime&quot;:{&quot;ts&quot;:{&quot;$timestamp&quot;:{&quot;t&quot;:1620079815,&quot;i&quot;:3}},&quot;t&quot;:1},&quot;electionId&quot;:{&quot;$oid&quot;:&quot;7fffffff0000000000000001&quot;},&quot;ok&quot;:1,&quot;$clusterTime&quot;:{&quot;clusterTime&quot;:{&quot;$timestamp&quot;:{&quot;t&quot;:1620079815,&quot;i&quot;:3}},&quot;signature&quot;:{&quot;hash&quot;:{&quot;$binary&quot;:&quot;AAAAAAAAAAAAAAAAAAAAAAAAAAA=&quot;,&quot;$type&quot;:&quot;00&quot;},&quot;keyId&quot;:0}},&quot;operationTime&quot;:{&quot;$timestamp&quot;:{&quot;t&quot;:1620079815,&quot;i&quot;:3}}}&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;&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;Documents in test.test:&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;0: {&quot;_id&quot;:{&quot;$oid&quot;:&quot;609074c70ba2e3bde8ab5281&quot;},&quot;AAA&quot;:1}&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;The AAA document is successfully inserted and the response is what we expect (n:1).&lt;/p&gt;

&lt;h4&gt;&lt;a name=&quot;Twoinserts&quot;&gt;&lt;/a&gt;Two inserts&lt;/h4&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;insert 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;insert&quot;:&quot;test&quot;,&quot;documents&quot;:[{&quot;BBB&quot;:1},{&quot;CCC&quot;:1}],&quot;txnNumber&quot;:1,&quot;$db&quot;:&quot;test&quot;,&quot;lsid&quot;:{&quot;id&quot;:{&quot;$binary&quot;:&quot;YXt1nbJBTWmgNPM+Vjug2A==&quot;,&quot;$type&quot;:&quot;04&quot;}},&quot;$clusterTime&quot;:{&quot;clusterTime&quot;:{&quot;$timestamp&quot;:{&quot;t&quot;:1620079815,&quot;i&quot;:3}},&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;&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;insert reply:&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;n&quot;:2,&quot;opTime&quot;:{&quot;ts&quot;:{&quot;$timestamp&quot;:{&quot;t&quot;:1620079815,&quot;i&quot;:4}},&quot;t&quot;:1},&quot;electionId&quot;:{&quot;$oid&quot;:&quot;7fffffff0000000000000001&quot;},&quot;ok&quot;:1,&quot;$clusterTime&quot;:{&quot;clusterTime&quot;:{&quot;$timestamp&quot;:{&quot;t&quot;:1620079815,&quot;i&quot;:4}},&quot;signature&quot;:{&quot;hash&quot;:{&quot;$binary&quot;:&quot;AAAAAAAAAAAAAAAAAAAAAAAAAAA=&quot;,&quot;$type&quot;:&quot;00&quot;},&quot;keyId&quot;:0}},&quot;operationTime&quot;:{&quot;$timestamp&quot;:{&quot;t&quot;:1620079815,&quot;i&quot;:4}}}&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;&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;Documents in test.test:&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;0: {&quot;_id&quot;:{&quot;$oid&quot;:&quot;609074c70ba2e3bde8ab5281&quot;},&quot;AAA&quot;:1}&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;1: {&quot;_id&quot;:{&quot;$oid&quot;:&quot;609074c70ba2e3bde8ab5285&quot;},&quot;CCC&quot;:1}&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;The insert contains two documents, but only CCC will be written to the collection. BBB is ultimately a no-op, because it shares the same statement ID as the previously inserted AAA (&quot;1.0&quot;). Since CCC is second in the &lt;tt&gt;documents&lt;/tt&gt; array and it has statement ID &quot;1.1&quot;. The response (n:2) does not match what has actually happened.&lt;/p&gt;

&lt;h4&gt;&lt;a name=&quot;Threeupserts&quot;&gt;&lt;/a&gt;Three upserts&lt;/h4&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;{&quot;update&quot;:&quot;test&quot;,&quot;updates&quot;:[{&quot;q&quot;:{&quot;DDD&quot;:1},&quot;u&quot;:{&quot;$inc&quot;:{&quot;DDD&quot;:1}},&quot;upsert&quot;:true},{&quot;q&quot;:{&quot;EEE&quot;:1},&quot;u&quot;:{&quot;$inc&quot;:{&quot;EEE&quot;:1}},&quot;upsert&quot;:true},{&quot;q&quot;:{&quot;FFF&quot;:1},&quot;u&quot;:{&quot;$inc&quot;:{&quot;FFF&quot;:1}},&quot;upsert&quot;:true}],&quot;txnNumber&quot;:1,&quot;$db&quot;:&quot;test&quot;,&quot;lsid&quot;:{&quot;id&quot;:{&quot;$binary&quot;:&quot;YXt1nbJBTWmgNPM+Vjug2A==&quot;,&quot;$type&quot;:&quot;04&quot;}},&quot;$clusterTime&quot;:{&quot;clusterTime&quot;:{&quot;$timestamp&quot;:{&quot;t&quot;:1620079815,&quot;i&quot;:4}},&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;&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;update reply:&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;n&quot;:3,&quot;nModified&quot;:0,&quot;upserted&quot;:[{&quot;index&quot;:0,&quot;_id&quot;:{&quot;$oid&quot;:&quot;609074c70ba2e3bde8ab5281&quot;}},{&quot;index&quot;:1,&quot;_id&quot;:{&quot;$oid&quot;:&quot;609074c70ba2e3bde8ab5285&quot;}},{&quot;index&quot;:2,&quot;_id&quot;:{&quot;$oid&quot;:&quot;609074c70ba2e3bde8ab5288&quot;}}],&quot;opTime&quot;:{&quot;ts&quot;:{&quot;$timestamp&quot;:{&quot;t&quot;:1620079815,&quot;i&quot;:5}},&quot;t&quot;:1},&quot;electionId&quot;:{&quot;$oid&quot;:&quot;7fffffff0000000000000001&quot;},&quot;ok&quot;:1,&quot;$clusterTime&quot;:{&quot;clusterTime&quot;:{&quot;$timestamp&quot;:{&quot;t&quot;:1620079815,&quot;i&quot;:5}},&quot;signature&quot;:{&quot;hash&quot;:{&quot;$binary&quot;:&quot;AAAAAAAAAAAAAAAAAAAAAAAAAAA=&quot;,&quot;$type&quot;:&quot;00&quot;},&quot;keyId&quot;:0}},&quot;operationTime&quot;:{&quot;$timestamp&quot;:{&quot;t&quot;:1620079815,&quot;i&quot;:5}}}&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;&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;Documents in test.test:&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;0: {&quot;_id&quot;:{&quot;$oid&quot;:&quot;609074c70ba2e3bde8ab5281&quot;},&quot;AAA&quot;:1}&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;1: {&quot;_id&quot;:{&quot;$oid&quot;:&quot;609074c70ba2e3bde8ab5285&quot;},&quot;CCC&quot;:1}&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;2: {&quot;_id&quot;:{&quot;$oid&quot;:&quot;609074c70ba2e3bde8ab5288&quot;},&quot;FFF&quot;:2}&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;The update contains three upserts, each of which match a single document (e.g. DDD:1) and increments the same key in its query. The first two upserts for DDD and EEE end up reusing previous statement IDs &quot;1.0&quot; and &quot;1.1&quot;, respectively, and are no-ops. The third upsert for FFF actually executes and we see a new document added to the collection. The response is misleading, as it suggests that three documents were upserted. ObjectIds for the previously inserted AAA and CCC documents are reported in the &lt;tt&gt;upserted&lt;/tt&gt; field alongside the one document that was actually upserted (FFF). An application might then infer that DDD and EEE have the same ObjectIds as AAA and CCC.&lt;/p&gt;

&lt;h4&gt;&lt;a name=&quot;Fourupdates&quot;&gt;&lt;/a&gt;Four updates&lt;/h4&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;{&quot;update&quot;:&quot;test&quot;,&quot;updates&quot;:[{&quot;q&quot;:{&quot;DDD&quot;:1},&quot;u&quot;:{&quot;$inc&quot;:{&quot;DDD&quot;:1}}},{&quot;q&quot;:{&quot;CCC&quot;:1},&quot;u&quot;:{&quot;$inc&quot;:{&quot;CCC&quot;:1}}},{&quot;q&quot;:{&quot;BBB&quot;:1},&quot;u&quot;:{&quot;$inc&quot;:{&quot;BBB&quot;:1}}},{&quot;q&quot;:{&quot;AAA&quot;:1},&quot;u&quot;:{&quot;$inc&quot;:{&quot;AAA&quot;:1}}}],&quot;txnNumber&quot;:1,&quot;$db&quot;:&quot;test&quot;,&quot;lsid&quot;:{&quot;id&quot;:{&quot;$binary&quot;:&quot;YXt1nbJBTWmgNPM+Vjug2A==&quot;,&quot;$type&quot;:&quot;04&quot;}},&quot;$clusterTime&quot;:{&quot;clusterTime&quot;:{&quot;$timestamp&quot;:{&quot;t&quot;:1620079815,&quot;i&quot;:5}},&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;&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;update reply:&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;n&quot;:4,&quot;nModified&quot;:1,&quot;upserted&quot;:[{&quot;index&quot;:0,&quot;_id&quot;:{&quot;$oid&quot;:&quot;609074c70ba2e3bde8ab5281&quot;}},{&quot;index&quot;:1,&quot;_id&quot;:{&quot;$oid&quot;:&quot;609074c70ba2e3bde8ab5285&quot;}},{&quot;index&quot;:2,&quot;_id&quot;:{&quot;$oid&quot;:&quot;609074c70ba2e3bde8ab5288&quot;}}],&quot;opTime&quot;:{&quot;ts&quot;:{&quot;$timestamp&quot;:{&quot;t&quot;:1620079815,&quot;i&quot;:6}},&quot;t&quot;:1},&quot;electionId&quot;:{&quot;$oid&quot;:&quot;7fffffff0000000000000001&quot;},&quot;ok&quot;:1,&quot;$clusterTime&quot;:{&quot;clusterTime&quot;:{&quot;$timestamp&quot;:{&quot;t&quot;:1620079815,&quot;i&quot;:6}},&quot;signature&quot;:{&quot;hash&quot;:{&quot;$binary&quot;:&quot;AAAAAAAAAAAAAAAAAAAAAAAAAAA=&quot;,&quot;$type&quot;:&quot;00&quot;},&quot;keyId&quot;:0}},&quot;operationTime&quot;:{&quot;$timestamp&quot;:{&quot;t&quot;:1620079815,&quot;i&quot;:6}}}&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;&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;Documents in test.test:&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;0: {&quot;_id&quot;:{&quot;$oid&quot;:&quot;609074c70ba2e3bde8ab5281&quot;},&quot;AAA&quot;:2}&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;1: {&quot;_id&quot;:{&quot;$oid&quot;:&quot;609074c70ba2e3bde8ab5285&quot;},&quot;CCC&quot;:1}&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;2: {&quot;_id&quot;:{&quot;$oid&quot;:&quot;609074c70ba2e3bde8ab5288&quot;},&quot;FFF&quot;:2}&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;The update contains four statements, each of which match a single document (DDD through AAA, in that order) and increments the same key in its query. The first three updates will reuse previous statement IDs (&quot;1.0&quot; through &quot;1.2&quot;) and be no-ops. The fourth update will match and increment AAA, which is what we see reflected in the collection. The &lt;tt&gt;nModified&lt;/tt&gt; field in the response is accurate but the &lt;tt&gt;upserted&lt;/tt&gt; field is misleading. Given that the &lt;tt&gt;upsert&lt;/tt&gt; option was not even used for these updates, an application would not expect any upserts to be reported.&lt;/p&gt;

&lt;h4&gt;&lt;a name=&quot;Sixdeletes&quot;&gt;&lt;/a&gt;Six deletes&lt;/h4&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;delete 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;delete&quot;:&quot;test&quot;,&quot;deletes&quot;:[{&quot;q&quot;:{&quot;EEE&quot;:1},&quot;limit&quot;:1},{&quot;q&quot;:{&quot;DDD&quot;:1},&quot;limit&quot;:1},{&quot;q&quot;:{&quot;CCC&quot;:1},&quot;limit&quot;:1},{&quot;q&quot;:{&quot;BBB&quot;:1},&quot;limit&quot;:1},{&quot;q&quot;:{&quot;AAA&quot;:1},&quot;limit&quot;:1},{&quot;q&quot;:{&quot;AAA&quot;:2},&quot;limit&quot;:1}],&quot;txnNumber&quot;:1,&quot;$db&quot;:&quot;test&quot;,&quot;lsid&quot;:{&quot;id&quot;:{&quot;$binary&quot;:&quot;YXt1nbJBTWmgNPM+Vjug2A==&quot;,&quot;$type&quot;:&quot;04&quot;}},&quot;$clusterTime&quot;:{&quot;clusterTime&quot;:{&quot;$timestamp&quot;:{&quot;t&quot;:1620079815,&quot;i&quot;:6}},&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;&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;delete reply:&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;n&quot;:5,&quot;opTime&quot;:{&quot;ts&quot;:{&quot;$timestamp&quot;:{&quot;t&quot;:1620079815,&quot;i&quot;:7}},&quot;t&quot;:1},&quot;electionId&quot;:{&quot;$oid&quot;:&quot;7fffffff0000000000000001&quot;},&quot;ok&quot;:1,&quot;$clusterTime&quot;:{&quot;clusterTime&quot;:{&quot;$timestamp&quot;:{&quot;t&quot;:1620079815,&quot;i&quot;:7}},&quot;signature&quot;:{&quot;hash&quot;:{&quot;$binary&quot;:&quot;AAAAAAAAAAAAAAAAAAAAAAAAAAA=&quot;,&quot;$type&quot;:&quot;00&quot;},&quot;keyId&quot;:0}},&quot;operationTime&quot;:{&quot;$timestamp&quot;:{&quot;t&quot;:1620079815,&quot;i&quot;:7}}}&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;&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;Documents in test.test:&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;0: {&quot;_id&quot;:{&quot;$oid&quot;:&quot;609074c70ba2e3bde8ab5285&quot;},&quot;CCC&quot;:1}&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;1: {&quot;_id&quot;:{&quot;$oid&quot;:&quot;609074c70ba2e3bde8ab5288&quot;},&quot;FFF&quot;:2}&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;The delete contains six statements. The first five statements match a single document (EEE through AAA, in that order) for value 1. The sixth statement matches AAA:2. All but the last two statements (AAA:1 and AAA:2) will be no-ops. Given the data in the collection, AAA:1 will match nothing, but AAA:2 will match and delete one document in the collection. Here, the result of n:5 suggests that five documents were actually deleted. Apart from the four no-op statements being counted, it looks as if the final two statements were accurately counted (only one of two resulted in a deletion).&lt;/p&gt;

&lt;h4&gt;&lt;a name=&quot;OnefindAndModify&quot;&gt;&lt;/a&gt;One findAndModify&lt;/h4&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;FFF&quot;:1},&quot;update&quot;:{&quot;$inc&quot;:{&quot;FFF&quot;:1}},&quot;upsert&quot;:true,&quot;new&quot;:true,&quot;txnNumber&quot;:1,&quot;$db&quot;:&quot;test&quot;,&quot;lsid&quot;:{&quot;id&quot;:{&quot;$binary&quot;:&quot;YXt1nbJBTWmgNPM+Vjug2A==&quot;,&quot;$type&quot;:&quot;04&quot;}},&quot;$clusterTime&quot;:{&quot;clusterTime&quot;:{&quot;$timestamp&quot;:{&quot;t&quot;:1620079815,&quot;i&quot;:7}},&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;&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 reply:&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;lastErrorObject&quot;:{&quot;n&quot;:1,&quot;updatedExisting&quot;:false,&quot;upserted&quot;:{&quot;$oid&quot;:&quot;609074c70ba2e3bde8ab5281&quot;}},&quot;value&quot;:{&quot;_id&quot;:{&quot;$oid&quot;:&quot;609074c70ba2e3bde8ab5281&quot;},&quot;AAA&quot;:1},&quot;ok&quot;:1,&quot;$clusterTime&quot;:{&quot;clusterTime&quot;:{&quot;$timestamp&quot;:{&quot;t&quot;:1620079815,&quot;i&quot;:7}},&quot;signature&quot;:{&quot;hash&quot;:{&quot;$binary&quot;:&quot;AAAAAAAAAAAAAAAAAAAAAAAAAAA=&quot;,&quot;$type&quot;:&quot;00&quot;},&quot;keyId&quot;:0}},&quot;operationTime&quot;:{&quot;$timestamp&quot;:{&quot;t&quot;:1620079815,&quot;i&quot;:7}}}&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;&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;Documents in test.test:&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;0: {&quot;_id&quot;:{&quot;$oid&quot;:&quot;609074c70ba2e3bde8ab5285&quot;},&quot;CCC&quot;:1}&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;1: {&quot;_id&quot;:{&quot;$oid&quot;:&quot;609074c70ba2e3bde8ab5288&quot;},&quot;FFF&quot;:2}&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;Finally, we attempt to repeat one of the earlier upserts using findAndModify for an FFF document. Since findAndModify consists of only a single statement, the entire command will be a no-op. The result suggests that a document was actually upserted, and it actually returns a copy of the AAA:1 document that was created by the first insert. This ignores that the document was later incremented and ultimately deleted. I think it&apos;s clear that this result is derived entirely from the original oplog entry corresponding to statement ID &quot;1.0&quot;.&lt;/p&gt;

&lt;h3&gt;&lt;a name=&quot;Possibleserverimprovements&quot;&gt;&lt;/a&gt;Possible server improvements&lt;/h3&gt;

&lt;p&gt;As mentioned in &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-3978&quot; title=&quot;Add entropy for OpenSSL RAND_bytes to avoid duplicate sequences for same PID&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-3978&quot;&gt;&lt;del&gt;SERVER-56137&lt;/del&gt;&lt;/a&gt;, there are a few possible server improvements that immediately come to mind:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Raise a server-side error if a command comes in using an lsid and txnNumber combination that was previously executed by a different command entirely. This may not be possible in all cases given that multiple commands can produce the same type of oplog entry, but it may be feasible in some cases. For example, a deletes should never produce an insert.&lt;/li&gt;
	&lt;li&gt;Even if a server-side errors are raised, having a different type of oplog entry &lt;em&gt;not&lt;/em&gt; count towards a different type&apos;s result would be an improvement (e.g. previous insert counting for a delete&apos;s &lt;tt&gt;n&lt;/tt&gt; result).&lt;/li&gt;
	&lt;li&gt;Include some checksum or hash of the original command (or at least its relevant parts) in the oplog entry, and raise an error if what the server considers a retry attempt fails a checksum match. This would have some overhead (both to calculate and store), but it would allow even multiple operations using the same command to be differentiated in most cases. There&apos;s still some edge cases it wouldn&apos;t cover: if the child processes in &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-3978&quot; title=&quot;Add entropy for OpenSSL RAND_bytes to avoid duplicate sequences for same PID&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-3978&quot;&gt;&lt;del&gt;SERVER-56137&lt;/del&gt;&lt;/a&gt; were all intentionally issuing the same command (e.g. $inc a field for the same document), we couldn&apos;t expect the server to see them as anything other than retry attempts.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt; I&apos;ll defer to server product/engineering to determine if any of these are worthwhile, but I&apos;ll understand if the entire premise of this issue comes across as a total edge case better left as-is.&lt;/p&gt;</description>
                <environment></environment>
        <key id="1699908">SERVER-56592</key>
            <summary>Unexpected results when different commands share the same lsid and txnNumber</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="13202">Works as Designed</resolution>
                                        <assignee username="judah.schvimer@mongodb.com">Judah Schvimer</assignee>
                                    <reporter username="jmikola@mongodb.com">Jeremy Mikola</reporter>
                        <labels>
                    </labels>
                <created>Mon, 3 May 2021 23:37:55 +0000</created>
                <updated>Fri, 27 Oct 2023 13:52:25 +0000</updated>
                            <resolved>Wed, 1 Dec 2021 16:51:06 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>7</watches>
                                                                                                                <comments>
                            <comment id="4224671" author="judah.schvimer" created="Wed, 1 Dec 2021 16:50:47 +0000"  >&lt;p&gt;Thanks &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=jmikola&quot; class=&quot;user-hover&quot; rel=&quot;jmikola&quot;&gt;jmikola&lt;/a&gt; for the issue and suggestions. I think that since this only happens when the client does not follow the protocol of using unique lsid/txnNumbers, the added complexity is not worth the gain at this time. Closing as &quot;Works as Designed&quot;, but definitely please reopen if you think the risk of future bugs like this is worth the complexity. CC &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=alan.zheng&quot; class=&quot;user-hover&quot; rel=&quot;alan.zheng&quot;&gt;alan.zheng&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                <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_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18555" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname># of Sprints</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1.0</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Wed, 1 Dec 2021 16:50:47 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        2 years, 10 weeks ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></customfieldvalue>


                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>luke.bonanomi@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            2 years, 10 weeks ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                    <customfield id="customfield_10032" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Operating System</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10026"><![CDATA[ALL]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>jmikola@mongodb.com</customfieldvalue>
            <customfieldvalue>judah.schvimer@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hz82br:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrfpfz:</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>
                                                                                                                                                                                                                                                                                                <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="5530">Replication 2021-12-13</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                    <customfieldvalue><![CDATA[edwin.zhou@mongodb.com]]></customfieldvalue>
    

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hz7okv:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                    </customfields>
    </item>
</channel>
</rss>