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.
- related to
-
SERVER-55092 [SBE] Fix shard filtering for hashed shard keys
- Closed
-
SERVER-55010 Enable sharding suite against SBE build variant
- Closed