Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-34338

find explain in legacy query path on mongos does not retry on StaleShardVersion

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 3.6.3, 3.7.3
    • Fix Version/s: 4.0.0, 4.1.1
    • Component/s: Sharding
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v4.0
    • Steps To Reproduce:
      Hide

      (function() {
          "use strict";
       
          const dbName = "test";
          const collName = "foo";
          const ns = dbName + "." + collName;
       
          const st = new ShardingTest({mongos: 2, shards: 1, verbose: 2});
       
          let staleMongos = st.s0;
          let freshMongos = st.s1;
       
          jsTest.log("Make the stale mongos load a cache entry for db " + dbName + " once");
          assert.writeOK(staleMongos.getDB(dbName).getCollection(collName).insert({_id: 1}));
       
          jsTest.log("Call shardCollection on " + ns + " from the fresh mongos");
          assert.commandWorked(freshMongos.adminCommand({enableSharding: dbName}));
          assert.commandWorked(freshMongos.adminCommand({shardCollection: ns, key: { "_id": 1 }}));
       
          jsTest.log("Ensure the shard knows " + ns + " is sharded");
          assert.commandWorked(st.shard0.adminCommand({_flushRoutingTableCacheUpdates: ns, syncFromConfig: true}));
       
          jsTest.log("Run explain find on " + ns + " from the stale mongos");
          // Expect the test to fail here.
          staleMongos.getDB(dbName).getCollection(collName).find({$query: {}, $explain: true}).next();
       
          st.stop();
      })();
      

      Show
      (function() { "use strict";   const dbName = "test"; const collName = "foo"; const ns = dbName + "." + collName;   const st = new ShardingTest({mongos: 2, shards: 1, verbose: 2});   let staleMongos = st.s0; let freshMongos = st.s1;   jsTest.log("Make the stale mongos load a cache entry for db " + dbName + " once"); assert.writeOK(staleMongos.getDB(dbName).getCollection(collName).insert({_id: 1}));   jsTest.log("Call shardCollection on " + ns + " from the fresh mongos"); assert.commandWorked(freshMongos.adminCommand({enableSharding: dbName})); assert.commandWorked(freshMongos.adminCommand({shardCollection: ns, key: { "_id": 1 }}));   jsTest.log("Ensure the shard knows " + ns + " is sharded"); assert.commandWorked(st.shard0.adminCommand({_flushRoutingTableCacheUpdates: ns, syncFromConfig: true}));   jsTest.log("Run explain find on " + ns + " from the stale mongos"); // Expect the test to fail here. staleMongos.getDB(dbName).getCollection(collName).find({$query: {}, $explain: true}).next();   st.stop(); })();
    • Sprint:
      Sharding 2018-05-21, Sharding 2018-06-04

      Description

      This is a regression introduce by this line in this commit on 3.6, where we pulled the StaleShardVersion handling in mongos up from scatterGather() to strategy::runCommand().

      There are no tests that run "find explain" (which is the only thing that goes through the legacy query path that does not internally handle StaleShardVersion) from a stale mongos with --shellReadMode=legacy, so this was not caught.

      See attached repro, which should be run with --shellReadMode=legacy to make the "find explain" go through the legacy query path on mongos.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              esha.maharishi Esha Maharishi
              Reporter:
              esha.maharishi Esha Maharishi
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: