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

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.0.0, 4.1.1
    • Affects Version/s: 3.6.3, 3.7.3
    • Component/s: Sharding
    • None
    • Fully Compatible
    • ALL
    • v4.0
    • 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(); })();
    • Sharding 2018-05-21, Sharding 2018-06-04

      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.

            Assignee:
            esha.maharishi@mongodb.com Esha Maharishi (Inactive)
            Reporter:
            esha.maharishi@mongodb.com Esha Maharishi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: