[SERVER-32282] Aggregation text search returns text score even if it wasn't requested when targeting multiple shards in a sharded cluster Created: 12/Dec/17  Updated: 30/Oct/23  Resolved: 16/Dec/17

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: 3.6.0
Fix Version/s: 3.6.2, 3.7.1

Type: Bug Priority: Major - P3
Reporter: Kyle Suarez Assignee: Bernard Gorman
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Related
is related to SERVER-32297 Aggregations that merge on mongos do ... Closed
is related to SERVER-22760 Sharded aggregation pipelines which i... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v3.6
Steps To Reproduce:

I think the easiest way is to try running existing tests: first, apply this patch to run with multiple shards:

diff --git a/buildscripts/resmokeconfig/suites/aggregation_sharded_collections_passthrough.yml b/buildscripts/resmokeconfig/suites/aggregation_sharded_collections_passthrough.yml
index de8b568eee..68b988f909 100644
--- a/buildscripts/resmokeconfig/suites/aggregation_sharded_collections_passthrough.yml
+++ b/buildscripts/resmokeconfig/suites/aggregation_sharded_collections_passthrough.yml
@@ -48,6 +48,7 @@ executor:
     n: 20
   fixture:
     class: ShardedClusterFixture
+    num_shards: 2
     mongos_options:
       set_parameters:
         enableTestCommands: 1

and then run

$ python2 buildscripts/resmoke.py --suites aggregation_sharded_collections_passthrough jstests/aggregation/bugs/server11675.js

With this patch applied, I can't reproduce the failure locally:

diff --git a/buildscripts/resmokeconfig/suites/aggregation_sharded_collections_passthrough.yml b/buildscripts/resmokeconfig/suites/aggregation_sharded_collections_passthrough.yml                                                            
index de8b568eee..1b2963cd71 100644
--- a/buildscripts/resmokeconfig/suites/aggregation_sharded_collections_passthrough.yml
+++ b/buildscripts/resmokeconfig/suites/aggregation_sharded_collections_passthrough.yml
@@ -48,9 +48,11 @@ executor:
     n: 20
   fixture:
     class: ShardedClusterFixture
+    num_shards: 2
     mongos_options:
       set_parameters:
         enableTestCommands: 1
+        internalQueryProhibitMergingOnMongoS: 1
     mongod_options:
       nopreallocj: ''
       set_parameters:

Sprint: Query 2017-12-18, Query 2018-01-01
Participants:

 Description   

As part of SERVER-31785, I noticed that an aggregation like

db.coll.aggregate({$match: {$text: {$search: "foo"}}});

will return the text score even though it hasn't been requested. This seems like a bug, as it differs from the behavior of the find command, which does not return the text score. Interestingly, this only occurs when the query targets multiple shards in the cluster. If I add a predicate on the shard key and target one shard, the text score is not included.

charlie.swanson noted that this might be related to the change in SERVER-22760, which allows merging on mongos for certain pipelines. I've confirmed that this doesn't reproduce when setting internalQueryProhibitMergingOnMongoS, so we should investigate the mongos merging logic.



 Comments   
Comment by Githook User [ 29/Dec/17 ]

Author:

{'username': 'gormanb', 'email': 'bernard.gorman@gmail.com', 'name': 'Bernard Gorman'}

Message: SERVER-32282 $textScore metadata is not removed in cases where RouterStagePipeline is optimized out on mongoS

(cherry picked from commit 6cbca62471218a08a4fdf8785bd1e1e38cf9bde3)
Branch: v3.6
https://github.com/mongodb/mongo/commit/7a9eff66dad1a2387b088cc0262cb004f4b7a18b

Comment by Githook User [ 16/Dec/17 ]

Author:

{'name': 'Bernard Gorman', 'email': 'bernard.gorman@gmail.com', 'username': 'gormanb'}

Message: SERVER-32282 $textScore metadata is not removed in cases where RouterStagePipeline is optimized out on mongoS
Branch: master
https://github.com/mongodb/mongo/commit/6cbca62471218a08a4fdf8785bd1e1e38cf9bde3

Comment by Bernard Gorman [ 13/Dec/17 ]

Thanks kyle.suarez, looking at this now. The reason this doesn't manifest for the single-shard case is that, when we can target the query to a single shard, we now pass the entire pipeline through to that shard and no split/merge semantics take place.

Generated at Thu Feb 08 04:29:47 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.