[SERVER-34248] Investigate why function_string_representation.js started failing Created: 02/Apr/18  Updated: 29/Oct/23  Resolved: 11/Jun/18

Status: Closed
Project: Core Server
Component/s: Testing Infrastructure
Affects Version/s: 3.7.3
Fix Version/s: 3.6.9, 4.0.0, 4.1.1

Type: Bug Priority: Major - P3
Reporter: Robert Guo (Inactive) Assignee: Robert Guo (Inactive)
Resolution: Fixed Votes: 0
Labels: tig-skip-pointing
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Problem/Incident
is caused by SERVER-32920 Avoid overriding read preference for ... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.0, v3.6
Sprint: TIG 2018-04-09, TIG 2018-05-21, TIG 2018-06-04, TIG 2018-06-18
Participants:
Linked BF Score: 68

 Comments   
Comment by Githook User [ 20/Sep/18 ]

Author:

{'name': 'Robert Guo', 'email': 'robert.guo@10gen.com', 'username': 'guoyr'}

Message: SERVER-34248 Add flag to temporarily bypass read preference override

(cherry picked from commit 59235c563bd0498fc796620169cfedc1b2307350)
Branch: v3.6
https://github.com/mongodb/mongo/commit/5aa45f9316c0de0f9a8514a28b63857519466f92

Comment by Githook User [ 11/Jun/18 ]

Author:

{'username': 'guoyr', 'name': 'Robert Guo', 'email': 'robert.guo@10gen.com'}

Message: SERVER-34248 Add flag to temporarily bypass read preference override

(cherry picked from commit 59235c563bd0498fc796620169cfedc1b2307350)
Branch: v4.0
https://github.com/mongodb/mongo/commit/cf23944c65308fe36d98a8a04647647f1b902200

Comment by Githook User [ 11/Jun/18 ]

Author:

{'username': 'guoyr', 'name': 'Robert Guo', 'email': 'robert.guo@10gen.com'}

Message: SERVER-34248 Add flag to temporarily bypass read preference override
Branch: master
https://github.com/mongodb/mongo/commit/59235c563bd0498fc796620169cfedc1b2307350

Comment by Robert Guo (Inactive) [ 04/Jun/18 ]

The error comes from this line to check if the collection is empty . When the config server uses an existing connection from its DBConn pool, regardless of whether it's to the primary or the secondary of a shard, the connection does not see the output of mapreduce, but when we create a new connection to one of the shard nodes, the new connection will take a new enough of a snapshot to see some or all of the data from the mapreduce call, causing the above line to error.

Applying the following one-line patch will allow the config server to establish a connection to the shard secondary and store it in the conn pool. So in the code linked above when the configsvr tries to contact the shard secondary again, the test passes. Note that we're assuming the same secondary is contacted, which indeed seems to be the case.

diff --git a/jstests/core/function_string_representations.js b/jstests/core/function_string_representations.js
index 211733e88f..84e6131344 100644
--- a/jstests/core/function_string_representations.js
+++ b/jstests/core/function_string_representations.js
@@ -20,12 +20,14 @@
 
     var mapFunction = "function() {emit(this._id, this.price);}";
     var reduceFunction = "function(keyCustId, valuesPrices) {return Array.sum(valuesPrices);}";
+    db.map_reduce_example.find();
     assert.commandWorked(col.mapReduce(mapFunction, reduceFunction, {out: "map_reduce_example"}));
-
+    // jsTestLog(tojson(db.getMongo().runCommand("test", {listIndexes: 'map_reduce_example'}, 0)));
     // Provided strings may end with semicolons and/or whitespace
     mapFunction += " ; ";
     reduceFunction += " ; ";
     assert.commandWorked(col.mapReduce(mapFunction, reduceFunction, {out: "map_reduce_example"}));
+    // printjson(db.getMongo().runCommand("test", {listIndexes: 'map_reduce_example'}, 0));
 
     // $where exhibits the same behavior
     var whereFunction = "function() {return this.price === 25;}";
diff --git a/jstests/libs/override_methods/enable_causal_consistency.js b/jstests/libs/override_methods/enable_causal_consistency.js
index 99a47401cd..c30105c616 100644
--- a/jstests/libs/override_methods/enable_causal_consistency.js
+++ b/jstests/libs/override_methods/enable_causal_consistency.js
@@ -8,6 +8,7 @@
     load('jstests/libs/override_methods/set_read_preference_secondary.js');
 
     db.getMongo().setCausalConsistency();
+    // db.getMongo().setReadPref('primary');
 
     OverrideHelpers.prependOverrideInParallelShell(
         "jstests/libs/override_methods/enable_causal_consistency.js");

I didn't dig further into why the result of mapreduce was not visible to established connections and only new ones.

Comment by Githook User [ 02/Apr/18 ]

Author:

{'email': 'robert.guo@10gen.com', 'name': 'Robert Guo', 'username': 'guoyr'}

Message: SERVER-34248 fix file name
Branch: master
https://github.com/mongodb/mongo/commit/5485a1a0b6b2d7f43c5f211e7a6fbf1e9889e0d3

Comment by Githook User [ 02/Apr/18 ]

Author:

{'email': 'robert.guo@10gen.com', 'name': 'Robert Guo', 'username': 'guoyr'}

Message: SERVER-34248 blacklist function_string_representation.js from sharded causal suite
Branch: master
https://github.com/mongodb/mongo/commit/1c2257457c1c566e84ea6ae6b0e42ac95336a709

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