<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:33:44 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-33538] mapReduce &quot;replace&quot; on a sharded output collection can lead to UUIDCatalog inconsistencies</title>
                <link>https://jira.mongodb.org/browse/SERVER-33538</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;mapReduce with a sharded output collection &lt;a href=&quot;https://github.com/mongodb/mongo/blob/de6ceb82f5b554f16517295adfd39c8bfd407926/src/mongo/db/commands/mr.cpp#L512-L520&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;assigns the UUID&lt;/a&gt; obtained from the config server to the final output collection. mapReduce &quot;replace&quot; will &lt;a href=&quot;https://github.com/mongodb/mongo/blob/r3.7.5/src/mongo/db/commands/mr.cpp#L681-L682&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;drop&lt;/a&gt; the existing output collection, which has the same UUID as the new output collection. Two-phase-drop may cause the dropCollection to finish after the &lt;a href=&quot;https://github.com/mongodb/mongo/blob/r3.7.5/src/mongo/db/commands/mr.cpp#L685-L689&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;renameCollection&lt;/a&gt; finishes, erroneously removing the UUIDCatalog entry for the output collection.&lt;/p&gt;</description>
                <environment></environment>
        <key id="503499">SERVER-33538</key>
            <summary>mapReduce &quot;replace&quot; on a sharded output collection can lead to UUIDCatalog inconsistencies</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="janna.golden@mongodb.com">Janna Golden</assignee>
                                    <reporter username="maria.vankeulen@mongodb.com">Maria van Keulen</reporter>
                        <labels>
                    </labels>
                <created>Wed, 28 Feb 2018 14:35:21 +0000</created>
                <updated>Sun, 29 Oct 2023 22:34:22 +0000</updated>
                            <resolved>Tue, 22 May 2018 21:01:27 +0000</resolved>
                                    <version>3.6.4</version>
                                    <fixVersion>3.6.6</fixVersion>
                    <fixVersion>4.0.0-rc1</fixVersion>
                    <fixVersion>4.1.1</fixVersion>
                                    <component>MapReduce</component>
                    <component>Sharding</component>
                                        <votes>0</votes>
                                    <watches>11</watches>
                                                                                                                <comments>
                            <comment id="1926855" author="xgen-internal-githook" created="Wed, 20 Jun 2018 22:06:14 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;username&apos;: &apos;jannaerin&apos;, &apos;name&apos;: &apos;jannaerin&apos;, &apos;email&apos;: &apos;golden.janna@gmail.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-33538&quot; title=&quot;mapReduce &amp;quot;replace&amp;quot; on a sharded output collection can lead to UUIDCatalog inconsistencies&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-33538&quot;&gt;&lt;del&gt;SERVER-33538&lt;/del&gt;&lt;/a&gt; Fix UUID inconsistencies in mapReduce on a sharded output collection&lt;br/&gt;
Branch: v3.6&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/a68b33ebd431c64315fa77f7c67914cb4b24a04a&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/a68b33ebd431c64315fa77f7c67914cb4b24a04a&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1917271" author="esha.maharishi@10gen.com" created="Mon, 11 Jun 2018 17:44:15 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=rribeiro&quot; class=&quot;user-hover&quot; rel=&quot;rribeiro&quot;&gt;rribeiro&lt;/a&gt;, I looked at the logs you attached on &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-35425&quot; title=&quot;After a map reduce an exception NamespaceNotFound happens in a secondary shard&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-35425&quot;&gt;&lt;del&gt;SERVER-35425&lt;/del&gt;&lt;/a&gt; and responded there.&lt;/p&gt;</comment>
                            <comment id="1917016" author="rribeiro" created="Mon, 11 Jun 2018 15:31:02 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=esha.maharishi&quot; class=&quot;user-hover&quot; rel=&quot;esha.maharishi&quot;&gt;esha.maharishi&lt;/a&gt;&#160;&lt;/p&gt;

&lt;p&gt;I understand your solution, but i am not using the option out: &quot;replace&quot;, I use the option out: &quot;reduce&quot;&lt;/p&gt;

&lt;p&gt;In my situation I do:&lt;/p&gt;

&lt;p&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;Pickup 3 Collections (sharded)&lt;/p&gt;

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

&lt;p&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; Map Reduce (out:reduce, sharded:true)&lt;/p&gt;

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

&lt;p&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; Ouput Collection(MR 1)&lt;/p&gt;

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

&lt;p&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;Map Reduce (out:reduce, sharded:true)&lt;/p&gt;

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

&lt;p&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; Ouput Collection(MR 2)&lt;/p&gt;

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

&lt;p&gt;Maybee my issue is variation of this bug:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-35425?page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel&amp;amp;focusedCommentId=1912268#comment-1912268&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://jira.mongodb.org/browse/SERVER-35425?page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel&amp;amp;focusedCommentId=1912268#comment-1912268&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;</comment>
                            <comment id="1916927" author="esha.maharishi@10gen.com" created="Mon, 11 Jun 2018 14:56:06 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=rribeiro&quot; class=&quot;user-hover&quot; rel=&quot;rribeiro&quot;&gt;rribeiro&lt;/a&gt;, I am not sure (&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=kelsey.schubert&quot; class=&quot;user-hover&quot; rel=&quot;kelsey.schubert&quot;&gt;kelsey.schubert&lt;/a&gt;?), but if you are running into this problem, you could run a collection drop on the sharded output collection before each mapReduce.&lt;/p&gt;

&lt;p&gt;This way, the mapReduce will create a new sharded output collection with a new UUID, rather than re-using the UUID from the existing sharded output collection, so you should not hit this bug.&lt;/p&gt;</comment>
                            <comment id="1916828" author="rribeiro" created="Mon, 11 Jun 2018 14:12:43 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=esha.maharishi&quot; class=&quot;user-hover&quot; rel=&quot;esha.maharishi&quot;&gt;esha.maharishi&lt;/a&gt;&#160;&lt;/p&gt;

&lt;p&gt;Thank you for the quick answer.&lt;/p&gt;

&lt;p&gt;Do you have any idea, when the next 3.6.x will be released.&lt;/p&gt;

&lt;p&gt;Right now, I am facing this problem, and without this fix I can&apos;t use 3.6.4.&lt;/p&gt;

&lt;p&gt;Cheers&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;</comment>
                            <comment id="1916806" author="esha.maharishi@10gen.com" created="Mon, 11 Jun 2018 14:02:58 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=rribeiro&quot; class=&quot;user-hover&quot; rel=&quot;rribeiro&quot;&gt;rribeiro&lt;/a&gt;, the plan is to backport the fix to the next 3.6 dot release &lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/smile.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&#160;&lt;/p&gt;</comment>
                            <comment id="1916583" author="rribeiro" created="Mon, 11 Jun 2018 10:09:38 +0000"  >&lt;p&gt;HI&lt;/p&gt;

&lt;p&gt;Do I have a way apply this fix in version 3.6.4, or will be just released on version 4.0.0?&lt;/p&gt;

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

&lt;p&gt;Thank you&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;</comment>
                            <comment id="1912906" author="esha.maharishi@10gen.com" created="Wed, 6 Jun 2018 20:01:17 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=janna.golden&quot; class=&quot;user-hover&quot; rel=&quot;janna.golden&quot;&gt;janna.golden&lt;/a&gt;, please review this table? My comments on the cr for the backport are based on this understanding:&lt;/p&gt;


&lt;div class=&apos;table-wrap&apos;&gt;
&lt;table class=&apos;confluenceTable&apos;&gt;&lt;tbody&gt;
&lt;tr&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;&lt;b&gt;3.4 mongos&lt;/b&gt;&lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;&lt;b&gt;3.6.x mongos (pre-backport)&lt;/b&gt;&lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;&lt;b&gt;3.6.y mongos (with backport)&lt;/b&gt;&lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;&lt;b&gt;4.0 mongos&lt;/b&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;&lt;ul&gt;
	&lt;li&gt;Just sends whether the output coll is sharded&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;&lt;ul&gt;
	&lt;li&gt;If output coll is sharded, sends &apos;finalOutputCollIsSharded&apos;&lt;/li&gt;
	&lt;li&gt;If found UUID (cluster is in FCV 3.6), sends &apos;shardedOutputCollUUID&apos;&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;&lt;ul&gt;
	&lt;li&gt;If merge/reduce and unsharded collection exists, fails.&lt;/li&gt;
	&lt;li&gt;If merge/reduce and sharded collection exists and is empty, or if replace:&lt;br/&gt;
&#160; &#160;- drops and re-shards the collection&lt;br/&gt;
&#160; &#160;- sends &apos;finalOutputCollIsSharded&apos;&lt;br/&gt;
&#160; &#160;- sends &apos;shardedOutputCollUUID&apos; with the new sharded collection&apos;s UUID&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;&lt;ul&gt;
	&lt;li&gt;If merge/reduce and unsharded collection exists, fails.&lt;/li&gt;
	&lt;li&gt;If merge/reduce and sharded collection exists and is empty, or if replace:&lt;br/&gt;
&#160; &#160;- drops and re-shards the collection&lt;br/&gt;
&#160; &#160;- sends &apos;shardedOutputCollUUID&apos; with the new sharded collection&apos;s UUID&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;&lt;b&gt;3.4 shard&lt;/b&gt;&lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;&lt;b&gt;3.6.x shard&lt;/b&gt;&lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;&lt;b&gt;3.6.y shard&lt;/b&gt;&lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;&lt;b&gt;4.0 shard&lt;/b&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;&lt;ul&gt;
	&lt;li&gt;Doesn&apos;t expect any UUID&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;&lt;ul&gt;
	&lt;li&gt;If received &apos;finalOutputCollIsSharded&apos; and in FCV 3.6, expects to have received &apos;shardedOutputCollUUID&apos;&lt;/li&gt;
	&lt;li&gt;If received &apos;shardedOutputCollUUID&apos;, expects the UUID to match the local collection&apos;s UUID (if a local collection exists)&lt;/li&gt;
	&lt;li&gt;Uses the sent UUID for the tmp collection (does not matter if rename happens)&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;&lt;ul&gt;
	&lt;li&gt;If received &apos;finalOutputCollIsSharded&apos; and is in FCV 3.6, expects to have received &apos;shardedOutputCollUUID&apos;&lt;/li&gt;
	&lt;li&gt;Uses the sent UUID for the tmp collection (assuming rename will happen)&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;&lt;ul&gt;
	&lt;li&gt;Uses the sent UUID for the tmp collection (assuming rename will happen)&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
</comment>
                            <comment id="1901804" author="xgen-internal-githook" created="Fri, 25 May 2018 14:57:37 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;username&apos;: &apos;jannaerin&apos;, &apos;name&apos;: &apos;jannaerin&apos;, &apos;email&apos;: &apos;golden.janna@gmail.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-33538&quot; title=&quot;mapReduce &amp;quot;replace&amp;quot; on a sharded output collection can lead to UUIDCatalog inconsistencies&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-33538&quot;&gt;&lt;del&gt;SERVER-33538&lt;/del&gt;&lt;/a&gt; Fix UUID inconsistencies in mapReduce on a sharded output collection&lt;/p&gt;

&lt;p&gt;(cherry picked from commit ff092947da81890ff92c427f50623d36d084e58c)&lt;br/&gt;
Branch: v4.0&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/29116784f5da27db0232dd91af056bfd646c109c&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/29116784f5da27db0232dd91af056bfd646c109c&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1899959" author="xgen-internal-githook" created="Wed, 23 May 2018 19:31:00 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;username&apos;: &apos;jannaerin&apos;, &apos;name&apos;: &apos;jannaerin&apos;, &apos;email&apos;: &apos;golden.janna@gmail.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-33538&quot; title=&quot;mapReduce &amp;quot;replace&amp;quot; on a sharded output collection can lead to UUIDCatalog inconsistencies&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-33538&quot;&gt;&lt;del&gt;SERVER-33538&lt;/del&gt;&lt;/a&gt; Fix UUID inconsistencies in mapReduce on a sharded output collection&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/ff092947da81890ff92c427f50623d36d084e58c&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/ff092947da81890ff92c427f50623d36d084e58c&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1899503" author="xgen-internal-githook" created="Wed, 23 May 2018 14:28:05 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;username&apos;: &apos;jannaerin&apos;, &apos;name&apos;: &apos;jannaerin&apos;, &apos;email&apos;: &apos;golden.janna@gmail.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-33538&quot; title=&quot;mapReduce &amp;quot;replace&amp;quot; on a sharded output collection can lead to UUIDCatalog inconsistencies&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-33538&quot;&gt;&lt;del&gt;SERVER-33538&lt;/del&gt;&lt;/a&gt; Fix UUID inconsistencies in mapReduce on a sharded output collection&lt;/p&gt;

&lt;p&gt;(cherry picked from commit b69e6725325aaaae4fcca7563bf6428837ab7767)&lt;br/&gt;
Branch: v4.0&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/6851604955969132ccf8521c1a6cfac7ec7ae2f7&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/6851604955969132ccf8521c1a6cfac7ec7ae2f7&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1899474" author="janna.golden" created="Wed, 23 May 2018 14:16:04 +0000"  >&lt;p&gt;This was committed with the wrong server ticket number, commit is above.&lt;/p&gt;</comment>
                            <comment id="1899473" author="janna.golden" created="Wed, 23 May 2018 14:15:38 +0000"  >&lt;p&gt;Author:&lt;/p&gt;

{&apos;username&apos;: &apos;jannaerin&apos;, &apos;name&apos;: &apos;jannaerin&apos;, &apos;email&apos;: &apos;golden.janna@gmail.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-33639&quot; title=&quot;Concurrent writes against non-existent database can fail due to distlock acquisition timeout at `createDatabase` time&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-33639&quot;&gt;&lt;del&gt;SERVER-33639&lt;/del&gt;&lt;/a&gt; Fix UUID inconsistencies in mapReduce on a sharded output collection&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/b69e6725325aaaae4fcca7563bf6428837ab7767&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/b69e6725325aaaae4fcca7563bf6428837ab7767&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1885928" author="esha.maharishi@10gen.com" created="Tue, 8 May 2018 15:34:45 +0000"  >&lt;p&gt;Thanks &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=asya&quot; class=&quot;user-hover&quot; rel=&quot;asya&quot;&gt;asya&lt;/a&gt; &lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/smile.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;.&lt;/p&gt;

&lt;p&gt;Also, I just discussed with Asya that dropping the output collection from the cluster before starting the second phase adds a &quot;window&quot; where queries on the output collection can see a &lt;b&gt;mix&lt;/b&gt;&#160;of&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;the old collection&apos;s data&lt;/li&gt;
	&lt;li&gt;empty results&lt;/li&gt;
	&lt;li&gt;the new collection&apos;s data&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;(because each shard will return data from one of these categories).&#160;Without this change, seeing &quot;empty results&quot; from any shard was not possible.&lt;/p&gt;

&lt;p&gt;We discussed that this is preferable to leaving the crash in the UUIDCatalog.&lt;/p&gt;</comment>
                            <comment id="1885913" author="asya" created="Tue, 8 May 2018 15:29:38 +0000"  >&lt;p&gt;&amp;gt;&#160;unless mapReduce with sharded out can only have _id as the shard key?&lt;/p&gt;

&lt;p&gt;Yes, we only allow (and work correctly) when output collection is sharded by _id.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;</comment>
                            <comment id="1870577" author="esha.maharishi@10gen.com" created="Fri, 20 Apr 2018 20:53:32 +0000"  >&lt;p&gt;Though, the shardCollection logic in dropAndShardCollection would need to not create the collection on the primary shard, which may be problematic because it won&apos;t create the shard key index... unless mapReduce with sharded out can only have _id as the shard key?&lt;/p&gt;</comment>
                            <comment id="1870574" author="esha.maharishi@10gen.com" created="Fri, 20 Apr 2018 20:50:57 +0000"  >&lt;p&gt;One sharding solution could be:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;add a &quot;dropAndShardCollection&quot; command on the config server. This command will hold distlocks across dropCollection and shardCollection logic, and return the new sharded collection&apos;s UUID. Mongos can send this new UUID in its sharded finish command, so that the asynchronous drop from dropAndShardCollection won&apos;t conflict with the rename from the sharded finish command.&lt;/li&gt;
	&lt;li&gt;for $out with replace, make the sharded finish command fail if the output collection already exists&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;We could take this one step further&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;make mongos hold the distlock across &quot;dropAndShardCollection&quot; as well as the sharded finish phase, which fixes related UUID bug &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-31716&quot; title=&quot;mapReduce can create sharded output collection on shards with wrong UUID if drop/recreate called concurrently&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-31716&quot;&gt;&lt;del&gt;SERVER-31716&lt;/del&gt;&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;As &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=schwerin&quot; class=&quot;user-hover&quot; rel=&quot;schwerin&quot;&gt;schwerin&lt;/a&gt; noted, doing either of these and backporting them does not guarantee that the crash will not occur in a mixed-version cluster v3.6/v4.0 cluster (unless all the v3.6 nodes have been upgraded to the 3.6 dot release that has the fix).&lt;/p&gt;</comment>
                            <comment id="1869561" author="maria.vankeulen" created="Thu, 19 Apr 2018 22:20:06 +0000"  >&lt;p&gt;I am assigning this to Sharding so they can investigate potential sharding-level fixes for this bug.&lt;/p&gt;</comment>
                            <comment id="1818506" author="maria.vankeulen" created="Wed, 28 Feb 2018 14:49:30 +0000"  >&lt;p&gt;One fix for this problem is to use immediate (not two-phase) collection drops during the &lt;a href=&quot;https://github.com/mongodb/mongo/blob/de6ceb82f5b554f16517295adfd39c8bfd407926/src/mongo/db/commands/mr.cpp#L671-L688&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&quot;replace&quot; stage&lt;/a&gt; and restore the UUIDCatalog entry for the output collection at the end of the &quot;replace&quot; stage before releasing the lock.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10420">
                    <name>Backports</name>
                                            <outwardlinks description="backported by">
                                                        </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                                        </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10320">
                    <name>Documented</name>
                                                                <inwardlinks description="is documented by">
                                        <issuelink>
            <issuekey id="548841">DOCS-11731</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                                                <inwardlinks description="is duplicated by">
                                        <issuelink>
            <issuekey id="504378">SERVER-33599</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="554746">SERVER-35425</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="530352">SERVER-34539</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                                        </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>19.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18555" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname># of Sprints</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>3.0</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_12450" key="com.atlassian.jira.plugin.system.customfieldtypes:multicheckboxes">
                        <customfieldname>Backport Requested</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="15640"><![CDATA[v4.0]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10011"><![CDATA[Minor Change]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Fri, 20 Apr 2018 20:50:57 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        5 years, 34 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>
                            5 years, 34 weeks ago
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_16465" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Linked BF Score</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>60.0</customfieldvalue>

                        </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>asya.kamsky@mongodb.com</customfieldvalue>
            <customfieldvalue>esha.maharishi@mongodb.com</customfieldvalue>
            <customfieldvalue>xgen-internal-githook</customfieldvalue>
            <customfieldvalue>janna.golden@mongodb.com</customfieldvalue>
            <customfieldvalue>maria.vankeulen@mongodb.com</customfieldvalue>
            <customfieldvalue>rribeiro</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|htrc07:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr8tyf:</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_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="2199">Storage NYC 2018-03-26</customfieldvalue>
    <customfieldvalue id="2290">Sharding 2018-05-21</customfieldvalue>
    <customfieldvalue id="2291">Sharding 2018-06-04</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>
                                

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

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