|
I haven't tracked down exactly why this is broken in existing stable versions, but I can confirm that this has been fixed as part of the mongos read path refactor done under SERVER-15176, so this issue will not affect 3.2. In the old mongos query code, mongos would extract the sort key from the result documents and use this for its merge sort. Something in this process appears to be broken.
The new query path instead issues a {$meta: "sortKey"} projection to the shards. (Sort key meta-projection was added in the 3.1 development cycle explicitly for this purpose.) This instructs each shard to return the sort key it generated for each result document as part of its response. Mongos then uses this sort key metadata to perform its mergesort. It then strips out the metadata before returning the result set to the client. This work was done under SERVER-19355.
|