<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 06:05:00 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-66289] $out incorrectly throws BSONObj size error on v5.0.8</title>
                <link>https://jira.mongodb.org/browse/SERVER-66289</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;In version 5, aggregation with $out as final stage is throwing BSONObj size (16MB) error even though individual documents are much smaller. It seems to be measuring the total size of all the documents in the result set.&lt;/p&gt;</description>
                <environment></environment>
        <key id="2041441">SERVER-66289</key>
            <summary>$out incorrectly throws BSONObj size error on v5.0.8</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="mihai.andrei@mongodb.com">Mihai Andrei</assignee>
                                    <reporter username="awanish@assetplus.io">Awanish Raj</reporter>
                        <labels>
                            <label>$out</label>
                            <label>aggregation</label>
                            <label>bug</label>
                    </labels>
                <created>Fri, 6 May 2022 17:30:53 +0000</created>
                <updated>Sun, 29 Oct 2023 21:38:31 +0000</updated>
                            <resolved>Tue, 16 Aug 2022 23:09:53 +0000</resolved>
                                    <version>5.0.8</version>
                                    <fixVersion>4.4.18</fixVersion>
                    <fixVersion>5.0.14</fixVersion>
                    <fixVersion>6.0.3</fixVersion>
                    <fixVersion>6.1.0-rc0</fixVersion>
                                    <component>Query Execution</component>
                    <component>Shell</component>
                                        <votes>2</votes>
                                    <watches>19</watches>
                                                                                                                <comments>
                            <comment id="4878710" author="xgen-internal-githook" created="Wed, 5 Oct 2022 04:03:07 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Mihai Andrei&apos;, &apos;email&apos;: &apos;mihai.andrei@10gen.com&apos;, &apos;username&apos;: &apos;mtandrei&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-66289&quot; title=&quot;$out incorrectly throws BSONObj size error on v5.0.8&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-66289&quot;&gt;&lt;del&gt;SERVER-66289&lt;/del&gt;&lt;/a&gt; Update write size estimation logic in DocumentSourceWriter&lt;/p&gt;

&lt;p&gt;(cherry picked from commit 707ba0a0ade42c4540b9cabaaf5a257de944cc3e)&lt;br/&gt;
(cherry picked from commit c172ccd37516f3c2118f349817cdb1841a2486b9)&lt;br/&gt;
(cherry picked from commit 3f2cd9485a807eaeabc60bd99653cffd2942f662)&lt;br/&gt;
Branch: v4.4&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/dad5d0a196ffb05b2c5c8b315c33ca46c8b65934&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/dad5d0a196ffb05b2c5c8b315c33ca46c8b65934&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="4876678" author="xgen-internal-githook" created="Tue, 4 Oct 2022 15:05:41 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Mihai Andrei&apos;, &apos;email&apos;: &apos;mihai.andrei@10gen.com&apos;, &apos;username&apos;: &apos;mtandrei&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-66289&quot; title=&quot;$out incorrectly throws BSONObj size error on v5.0.8&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-66289&quot;&gt;&lt;del&gt;SERVER-66289&lt;/del&gt;&lt;/a&gt; Update write size estimation logic in DocumentSourceWriter&lt;/p&gt;

&lt;p&gt;(cherry picked from commit 707ba0a0ade42c4540b9cabaaf5a257de944cc3e)&lt;br/&gt;
(cherry picked from commit c172ccd37516f3c2118f349817cdb1841a2486b9)&lt;br/&gt;
Branch: v5.0&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/3f2cd9485a807eaeabc60bd99653cffd2942f662&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/3f2cd9485a807eaeabc60bd99653cffd2942f662&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="4875133" author="xgen-internal-githook" created="Tue, 4 Oct 2022 01:06:34 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Mihai Andrei&apos;, &apos;email&apos;: &apos;mihai.andrei@10gen.com&apos;, &apos;username&apos;: &apos;mtandrei&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-66289&quot; title=&quot;$out incorrectly throws BSONObj size error on v5.0.8&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-66289&quot;&gt;&lt;del&gt;SERVER-66289&lt;/del&gt;&lt;/a&gt; Update write size estimation logic in DocumentSourceWriter&lt;/p&gt;

&lt;p&gt;(cherry picked from commit 707ba0a0ade42c4540b9cabaaf5a257de944cc3e)&lt;br/&gt;
Branch: v6.0&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/c172ccd37516f3c2118f349817cdb1841a2486b9&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/c172ccd37516f3c2118f349817cdb1841a2486b9&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="4874360" author="mihai.andrei" created="Mon, 3 Oct 2022 20:03:40 +0000"  >&lt;p&gt;The real commit that wound up in master:&#160;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/mongodb/mongo/commit/707ba0a0ade42c4540b9cabaaf5a257de944cc3e&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/707ba0a0ade42c4540b9cabaaf5a257de944cc3e&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(note that &lt;a href=&quot;https://github.com/mongodb/mongo/commit/7b7fe658db948e6f5a4a6c30d4590d7866c59371&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/7b7fe658db948e6f5a4a6c30d4590d7866c59371&lt;/a&gt; was reverted)&lt;/p&gt;

&lt;p&gt;I wonder why the githook didn&apos;t pick this one up... oh well&lt;/p&gt;</comment>
                            <comment id="4868889" author="xgen-internal-githook" created="Fri, 30 Sep 2022 15:16:10 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Uladzimir Makouski&apos;, &apos;email&apos;: &apos;uladzimir.makouski@mongodb.com&apos;, &apos;username&apos;: &apos;umakouski&apos;}
&lt;p&gt;Message: Revert &quot;&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-66289&quot; title=&quot;$out incorrectly throws BSONObj size error on v5.0.8&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-66289&quot;&gt;&lt;del&gt;SERVER-66289&lt;/del&gt;&lt;/a&gt; Update write size estimation logic in DocumentSourceWriter&quot;&lt;/p&gt;

&lt;p&gt;This reverts commit dff46e92439898e1012f93ee7ca82d35ad88dae5.&lt;br/&gt;
Branch: v6.0&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/814ad525328e887add796abd0940563da33d0224&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/814ad525328e887add796abd0940563da33d0224&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="4867193" author="xgen-internal-githook" created="Thu, 29 Sep 2022 23:18:21 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Mihai Andrei&apos;, &apos;email&apos;: &apos;mihai.andrei@10gen.com&apos;, &apos;username&apos;: &apos;mtandrei&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-66289&quot; title=&quot;$out incorrectly throws BSONObj size error on v5.0.8&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-66289&quot;&gt;&lt;del&gt;SERVER-66289&lt;/del&gt;&lt;/a&gt; Update write size estimation logic in DocumentSourceWriter&lt;/p&gt;

&lt;p&gt;(cherry picked from commit 7b7fe658db948e6f5a4a6c30d4590d7866c59371)&lt;br/&gt;
Branch: v6.0&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/dff46e92439898e1012f93ee7ca82d35ad88dae5&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/dff46e92439898e1012f93ee7ca82d35ad88dae5&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="4827644" author="JIRAUSER1271161" created="Wed, 14 Sep 2022 21:24:48 +0000"  >&lt;p&gt;Thanks!&lt;/p&gt;</comment>
                            <comment id="4827257" author="kyle.suarez" created="Wed, 14 Sep 2022 19:39:51 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=larsvancasteren%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;larsvancasteren@gmail.com&quot;&gt;larsvancasteren@gmail.com&lt;/a&gt;, the fix in this ticket is present in 6.1.0-rc0; however, the team has not yet backported the fix to previous branches. We&apos;ve requested backport to the v6.0, v5.0 and v4.4 versions. Please continue to watch this ticket for updates and thank you for your patience.&lt;/p&gt;

&lt;p&gt;Kyle&lt;/p&gt;</comment>
                            <comment id="4827242" author="JIRAUSER1271161" created="Wed, 14 Sep 2022 19:35:20 +0000"  >&lt;p&gt;MongoDB 4.4.15&lt;/p&gt;

&lt;p&gt;When updating a $out (aggregation) on a primary node without any readPreference it runs successful.&lt;br/&gt;
When running the same $out aggregation using the secondary node readPreference approach we get this error:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;BSONObj size: 16953146 (0x102AF3A) is invalid.&lt;br/&gt;
Size must be between 0 and 16793600(16MB) First element:&lt;br/&gt;
insert: &quot; tmp.agg_out.55125f65 - 0ef0 - 4c1f - a7ef - dec311c99612 &quot;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;For completness: &lt;a href=&quot;https://www.mongodb.com/community/forums/t/mongodb-4-4-15-bsonobjecttoolarge-aggregation-out-update/186983&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://www.mongodb.com/community/forums/t/mongodb-4-4-15-bsonobjecttoolarge-aggregation-out-update/186983&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Gr,&lt;br/&gt;
L&lt;/p&gt;</comment>
                            <comment id="4710441" author="xgen-internal-githook" created="Wed, 27 Jul 2022 23:39:07 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Mihai Andrei&apos;, &apos;email&apos;: &apos;mihai.andrei@10gen.com&apos;, &apos;username&apos;: &apos;mtandrei&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-66289&quot; title=&quot;$out incorrectly throws BSONObj size error on v5.0.8&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-66289&quot;&gt;&lt;del&gt;SERVER-66289&lt;/del&gt;&lt;/a&gt; Update write size estimation logic in DocumentSourceWriter&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/7b7fe658db948e6f5a4a6c30d4590d7866c59371&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/7b7fe658db948e6f5a4a6c30d4590d7866c59371&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="4587767" author="mihai.andrei" created="Wed, 1 Jun 2022 18:59:28 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=awanish%40assetplus.io&quot; class=&quot;user-hover&quot; rel=&quot;awanish@assetplus.io&quot;&gt;awanish@assetplus.io&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;Thanks for filing this ticket and reporting this issue! After doing some investigation, there does appear to be an issue with how the server handles batches of writes when running $out with secondary read preference. One thing I would like to note however, is that when investigating, I was able to reproduce the issue on 4.4 as well as 5.0. Would you be able to confirm that when you ran your aggregation with secondary read preference on 4.4, that the aggregate succeeded? Also, which shell did you use? I would like to rule out the possibility of a separate issue (that of the shell or drivers not respecting read preference).&lt;/p&gt;</comment>
                            <comment id="4570021" author="JIRAUSER1265262" created="Tue, 24 May 2022 17:00:14 +0000"  >&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;Given that this issue appears to be behaving inconsistently depending on where the query is ran from, I&apos;m going to forward this to Driver Escalation for further investigation, given that:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;https://www.mongodb.com/docs/manual/reference/operator/aggregation/out/#-out-read-operations-run-on-secondary-replica-set-members&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;there is an existing driver warning in the docs for $out here:&lt;/a&gt;&lt;/li&gt;
&lt;/ul&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;   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;Not all driver versions support targeting of $out operations to replica set secondary nodes. Check your driver documentation to see when your driver added support &lt;/span&gt;&lt;span style=&quot;color: #006699; font-weight: bold; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;for&lt;/span&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; $out running on a secondary.&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;ul&gt;
	&lt;li&gt;The same query on the same data is behaving differently based on where it is going (Atlas vs local replica set)&lt;/li&gt;
	&lt;li&gt;This may be affecting $merge as well, which has the &lt;a href=&quot;https://www.mongodb.com/docs/manual/reference/operator/aggregation/merge/#mongodb-pipeline-pipe.-merge&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;same warning in the docs.&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;Christopher&lt;/p&gt;</comment>
                            <comment id="4546302" author="JIRAUSER1269887" created="Thu, 12 May 2022 20:26:11 +0000"  >&lt;p&gt;Seeing this issue as well; a few details from my team&apos;s end:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;When running code locally on a Windows workstation pointed to Atlas cluster, aggregation succeeds. When code executes from a container in a Linux based K8s cluster pointed to the same Atlas cluster, aggregation fails with:
	&lt;ul&gt;
		&lt;li&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;// Anonymized method executions&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;Error while indexing: Command aggregate failed: PlanExecutor error during aggregation :: caused by :: BSONObj size: 16813584 (0x1008E10) is invalid. Size must be between 0 and 16793600(16MB) First element: insert: &quot;tmp.agg_out.d03d9e58-98fd-44ed-bed0-4242d6ffafce&quot;.&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;MongoDB.Driver.MongoCommandException: Command aggregate failed: PlanExecutor error during aggregation :: caused by :: BSONObj size: 16813584 (0x1008E10) is invalid. Size must be between 0 and 16793600(16MB) First element: insert: &quot;tmp.agg_out.d03d9e58-98fd-44ed-bed0-4242d6ffafce&quot;.&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;    at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol`1.ProcessResponse(ConnectionId connectionId, CommandMessage responseMessage)&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;    at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol`1.ExecuteAsync(IConnection connection, CancellationToken cancellationToken)&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;    at MongoDB.Driver.Core.Servers.Server.ServerChannel.ExecuteProtocolAsync[TResult](IWireProtocol`1 protocol, ICoreSession session, CancellationToken cancellationToken)&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;    at MongoDB.Driver.Core.Operations.CommandOperationBase`1.ExecuteProtocolAsync(IChannelSource channelSource, ICoreSessionHandle session, ReadPreference readPreference, CancellationToken cancellationToken)&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;    at MongoDB.Driver.Core.Operations.WriteCommandOperation`1.ExecuteAsync(IWriteBinding binding, CancellationToken cancellationToken)&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;    at MongoDB.Driver.Core.Operations.AggregateToCollectionOperation.ExecuteAsync(IWriteBinding binding, CancellationToken cancellationToken)&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;    at MongoDB.Driver.OperationExecutor.ExecuteWriteOperationAsync[TResult](IWriteBinding binding, IWriteOperation`1 operation, CancellationToken cancellationToken)&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;    at MongoDB.Driver.MongoCollectionImpl`1.ExecuteWriteOperationAsync[TResult](IClientSessionHandle session, IWriteOperation`1 operation, CancellationToken cancellationToken)&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;    at MongoDB.Driver.MongoCollectionImpl`1.AggregateAsync[TResult](IClientSessionHandle session, PipelineDefinition`2 pipeline, AggregateOptions options, CancellationToken cancellationToken)&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;    at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSessionAsync[TResult](Func`2 funcAsync, CancellationToken cancellationToken)&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;    at **REDACTED**&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;    at **REDACTED**&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;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li&gt;Setting the &lt;tt&gt;readPreference&lt;/tt&gt; to &lt;tt&gt;primary&lt;/tt&gt; as a workaround worked for us (kudos to @Awanish Raj).&lt;/li&gt;
	&lt;li&gt;From what I&apos;ve read on &lt;tt&gt;batchSize&lt;/tt&gt; being set on the cursor, the total result of each batch must be less than 16MB; not just the document size. I wouldn&apos;t expect the &lt;tt&gt;$out&lt;/tt&gt; stage to be done in batches, but seemed worth mentioning.&lt;/li&gt;
&lt;/ol&gt;
</comment>
                            <comment id="4537381" author="JIRAUSER1269405" created="Tue, 10 May 2022 07:53:45 +0000"  >&lt;p&gt;The issue happens only if readPreference was &quot;secondary&quot;. If no readPreference is given, the command succeeds.&lt;/p&gt;</comment>
                            <comment id="4537177" author="JIRAUSER1269405" created="Tue, 10 May 2022 03:33:54 +0000"  >&lt;p&gt;The error pops up when using Realm Triggers (In production) and MongoDB Compass Shell (In testing) to run this command so far. When I ran the same from mongosh in terminal, there was no issue and it succeeded.&lt;/p&gt;</comment>
                            <comment id="4532066" author="JIRAUSER1269405" created="Fri, 6 May 2022 17:55:34 +0000"  >&lt;p&gt;I have verified that the aggregation succeeds on v4.4.13, but fails on v5.0.8 and v5.3.1.&lt;/p&gt;</comment>
                            <comment id="4532021" author="JIRAUSER1269405" created="Fri, 6 May 2022 17:35:59 +0000"  >&lt;p&gt;I have tested it with v5.3 on Atlas. The issue remains.&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="10520">
                    <name>Problem/Incident</name>
                                            <outwardlinks description="causes">
                                                        </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="2108223">SERVER-68845</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="2180691">SERVER-71238</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                            <attachment id="378215" name="screenshot-1.png" size="27500" author="alex.bevilacqua@mongodb.com" created="Tue, 10 May 2022 18:44:40 +0000"/>
                            <attachment id="378216" name="screenshot-2.png" size="36706" author="alex.bevilacqua@mongodb.com" created="Tue, 10 May 2022 18:45:21 +0000"/>
                            <attachment id="378217" name="screenshot-3.png" size="77638" author="alex.bevilacqua@mongodb.com" created="Tue, 10 May 2022 18:47:27 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>17.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18555" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname># of Sprints</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>7.0</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_12450" key="com.atlassian.jira.plugin.system.customfieldtypes:multicheckboxes">
                        <customfieldname>Backport Requested</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="23470"><![CDATA[v6.0]]></customfieldvalue>
    <customfieldvalue key="21777"><![CDATA[v5.0]]></customfieldvalue>
    <customfieldvalue key="18953"><![CDATA[v4.4]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10038"><![CDATA[Fully Compatible]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                    <customfield id="customfield_13552" key="com.go2group.jira.plugin.crm:crm_generic_field">
                        <customfieldname>Case</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[[5006R00001lPnQVQA0, 5006R00001oIAj9QAG]]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Tue, 10 May 2022 17:05:13 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        1 year, 18 weeks, 1 day 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_17050" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Downstream Team Attention</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="16941"><![CDATA[Not Needed]]></customfieldvalue>

                        </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>
                            1 year, 18 weeks, 1 day ago
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_16465" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Linked BF Score</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>170.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>awanish@assetplus.io</customfieldvalue>
            <customfieldvalue>chris.kelly@mongodb.com</customfieldvalue>
            <customfieldvalue>crtaylor@verisk.com</customfieldvalue>
            <customfieldvalue>xgen-internal-githook</customfieldvalue>
            <customfieldvalue>kyle.suarez@mongodb.com</customfieldvalue>
            <customfieldvalue>larsvancasteren@gmail.com</customfieldvalue>
            <customfieldvalue>mihai.andrei@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|i0tzjz:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|i0bhpm:</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_22250" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Special Downgrade Instructions Required</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="23343"><![CDATA[Not Needed]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="5894">QE 2022-05-30</customfieldvalue>
    <customfieldvalue id="5896">QE 2022-06-13</customfieldvalue>
    <customfieldvalue id="5898">QE 2022-06-27</customfieldvalue>
    <customfieldvalue id="5900">QE 2022-07-11</customfieldvalue>
    <customfieldvalue id="5902">QE 2022-07-25</customfieldvalue>
    <customfieldvalue id="5904">QE 2022-08-08</customfieldvalue>
    <customfieldvalue id="5906">QE 2022-08-22</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10750" key="com.atlassian.jira.plugin.system.customfieldtypes:textarea">
                        <customfieldname>Steps To Reproduce</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>&lt;p&gt;Steps followed:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;Launch M10 cluster on Atlas and load sample dataset.&lt;/li&gt;
	&lt;li&gt;In the shell, use sample_mflix db&lt;/li&gt;
	&lt;li&gt;Run aggregation command: db.movies.aggregate(&lt;span class=&quot;error&quot;&gt;&amp;#91;{$out: &amp;quot;movies2&amp;quot;}&amp;#93;&lt;/span&gt;)&lt;/li&gt;
&lt;/ol&gt;


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

&lt;p&gt;On version 4.4.13:&lt;/p&gt;

&lt;p&gt;The command runs successfully and movies2 collection is created.&lt;/p&gt;

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

&lt;p&gt;On version 5.0.8:&lt;/p&gt;

&lt;p&gt;The command fails with the error:&lt;/p&gt;

&lt;p&gt;PlanExecutor error during aggregation :: caused by :: BSONObj size: 16836845 (0x100E8ED) is invalid. Size must be between 0 and 16793600(16MB) First element: insert: &quot;tmp.agg_out.045d5052-e014-4830-8d16-5b985ebfc46e&quot;&lt;/p&gt;</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[chris.kelly@mongodb.com]]></customfieldvalue>
    

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

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