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

[sbe][sharding] Expected 1 chunk skip but saw none in shard3.js

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.0.0-rc0
    • Affects Version/s: None
    • Component/s: Querying, Sharding
    • None
    • Fully Compatible
    • ALL
    • Query Execution 2021-05-03

      The test asserts that we have 1 chunk skipped in a SHARDING_FILTER stage:

      var e = a.find().explain("executionStats").executionStats;
      assert.eq(3, e.nReturned, "ex1");
      assert.eq(0, e.totalKeysExamined, "ex2");
      assert.eq(4, e.totalDocsExamined, "ex3");
      
      var chunkSkips = 0;
      for (var shard in e.executionStages.shards) {
          var theShard = e.executionStages.shards[shard];
          chunkSkips += getChunkSkips(theShard.executionStages);
      }
      assert.eq(1, chunkSkips, "ex4"); // <----- fails
      

      In the error, we got no chunk skips at all:

      [js_test:shard3] uncaught exception: Error: [1] != [0] are not equal : ex4 :
      [js_test:shard3] doassert@src/mongo/shell/assert.js:20:14
      [js_test:shard3] assert.eq@src/mongo/shell/assert.js:179:9
      [js_test:shard3] @jstests/sharding/shard3.js:91:1
      [js_test:shard3] @jstests/sharding/shard3.js:1:2
      [js_test:shard3] failed to load: jstests/sharding/shard3.js
      [js_test:shard3] exiting with code -3
      

      The analyze plan helper looks for a SHARDING_FILTER stage in the explain output and extracts the chunkSkips field:

      /**
       * Get the number of chunk skips for the BSON exec stats tree rooted at 'root'.
       */
      function getChunkSkips(root) {
          if (root.stage === "SHARDING_FILTER") {
              return root.chunkSkips;
          } else if ("inputStage" in root) {
              return getChunkSkips(root.inputStage);
          } else if ("inputStages" in root) {
              var skips = 0;
              for (var i = 0; i < root.inputStages.length; i++) {
                  skips += getChunkSkips(root.inputStages[0]);
              }
              return skips;
          }
      
          return 0;
      }
      

      Also, "shard3.js" is one of those old tests that should improve the error message reported when this assertion does trip.

            Assignee:
            justin.seyster@mongodb.com Justin Seyster
            Reporter:
            kyle.suarez@mongodb.com Kyle Suarez
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: