[DOCS-11469] Ambiguity about Where the Merge Sort Occurs in a Sharded Cluster Created: 20/Mar/18  Updated: 29/Oct/23  Resolved: 02/Mar/21

Status: Closed
Project: Documentation
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Ravind Kumar (Inactive) Assignee: Andrew Feierabend (Inactive)
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Documented
documents SERVER-17737 Support distributed merger for aggreg... Open
Related
related to DOCS-13229 Conflicting info about Aggregation pi... Closed
related to DOCS-8582 Update v3.2, v3.0, and v2.6 versions ... Closed
Participants:
Days since reply: 1 year, 42 weeks, 6 days ago
Story Points: 0

 Description   

The documentation states, in different places, that a merge sort occurs on the mongos, or on the Primary database of the collection. The documentation may need to be reconciled, or, if I'm misunderstanding what's being communicated, clarified.

I believe that the mongos is the only shard that merge-sorts the results of a .find() query.

Statements in favor of each:

  • the primary shard
    • "If the query specifies sorted results using the sort() cursor method, the mongos instance passes the $orderby option to the shards. The primary shard for the database receives and performs a merge sort for all results before returning the data to the client via the mongos."
  • the mongos
    • "If you call the cursor.sort() method on a query in a sharded environment, the mongod for each shard will sort its results, and the mongos merges each shard’s results before returning them to the client."

I also note that the explanation references the $orderby option, which, according to the documentation, is deprecated as of 3.2.



 Comments   
Comment by Jess Mokrzecki [ 14/Apr/22 ]

Fix Version updated for upstream SERVER-17737:

Comment by Kay Kim (Inactive) [ 23/Jun/20 ]

Commits per Asya's pull request :

Branch: master
https://github.com/mongodb/docs/commit/5c0d94f91db602edd57e688c45b8425546ba1a9e

Branch: v4.2
https://github.com/mongodb/docs/commit/ce4f8c163e88bd9287186fb8f0d500b2b2ffdb23

Branch: v4.0
https://github.com/mongodb/docs/commit/5c0d94f91db602edd57e688c45b8425546ba1a9e

 

Branch: v3.6

https://github.com/mongodb/docs/commit/6c8d275ae82e7a9428ada0ef073e2e4ec608fbbb

Comment by Githook User [ 13/Nov/18 ]

Author:

{'name': 'ravind', 'email': 'ravind.kumar@10gen.com', 'username': 'rkumar-mongo'}

Message: DOCS-11469: Removing paragraph, future work to provide better clarification on topic
Branch: v3.6
https://github.com/mongodb/docs/commit/e44023c29055205252699581d294760345c5af8a

Comment by Githook User [ 13/Nov/18 ]

Author:

{'name': 'ravind', 'email': 'ravind.kumar@10gen.com', 'username': 'rkumar-mongo'}

Message: DOCS-11469: Removing paragraph, future work to provide better clarification on topic
Branch: v4.0
https://github.com/mongodb/docs/commit/aac36434e758ae665f56a071bf8e86ebbd65cb51

Comment by Githook User [ 13/Nov/18 ]

Author:

{'name': 'ravind', 'email': 'ravind.kumar@10gen.com', 'username': 'rkumar-mongo'}

Message: DOCS-11469: Removing paragraph, future work to provide better clarification on topic
Branch: master
https://github.com/mongodb/docs/commit/f7c29fa6f6a9e22753de36302654b1fabf2be608

Comment by Ravind Kumar (Inactive) [ 13/Nov/18 ]

https://github.com/mongodb/docs/pull/3485 <- For the short term, I'm removing the paragraph until we've fully reviewed the information as provided by bernard.gorman . At that point we can create clear and concise documentation describing merge sort behavior.

Comment by Ravind Kumar (Inactive) [ 02/Oct/18 ]

If you have bandwidth to handle next week, that would be ideal. If not, I'll find someone to handle.

Comment by Susan Kerschbaumer (Inactive) [ 02/Oct/18 ]

ravind.kumar I somehow missed this ticket – I'm wondering if someone in server would be able to pick this up now? I could revisit next week if not.

Comment by Ravind Kumar (Inactive) [ 20/Mar/18 ]

Hi sue.kerschbaumer!

So the original work on DOCS-7237 captured most of the changes required to correct the ambiguity, but there are two remaining sections that still need corrections:

1) https://docs.mongodb.com/manual/core/sharded-cluster-query-router/#sorting

Via David's commentary, the merge sort always occurs on the mongos for find operations. For aggregation operations, the merge-sort occurs on a random shard.

2) https://docs.mongodb.com/manual/core/sharded-cluster-query-router/#routing-and-results-process

This paragraph also references the primary shard as responsible for merge sorting.

Generated at Thu Feb 08 08:02:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.