-
Type:
Bug
-
Resolution: Works as Designed
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Integration
-
ALL
When using the $queryStats aggregation stage, the keys sometimes differ slightly between mongod and mongos, even when using the exact same query. Specifically, mongos adds a readConcern field and mongod adds a collectionType field. To illustrate, consider the following js:
import { getQueryStats } from "jstests/libs/query_stats_utils.js"; function queryAndGetStats(conn) { const db = conn.getDB("test"); const coll = db.getCollection("example_query_shape_key"); coll.insert([{x: 1}, {x: 2}]); coll.find({x: 1}).sort({v: 1}).batchSize(100).toArray(); return getQueryStats(db, {collName: coll.getName()})[0]; } const options = { setParameter: {internalQueryStatsRateLimit: -1} }; const conn = MongoRunner.runMongod(options); const statsMongod = queryAndGetStats(conn); MongoRunner.stopMongod(conn); let st = new ShardingTest(Object.assign({shards: 2, other: {mongosOptions: options}})); const statsMongos = queryAndGetStats(st.s); st.stop(); print("mongod readConcern\n\t" + tojson(statsMongod.key.readConcern)); print("mongos readConcern\n\t" + tojson(statsMongos.key.readConcern)); print("mongod collectionType\n\t" + tojson(statsMongod.key.collectionType)); print("mongos collectionType\n\t" + tojson(statsMongos.key.collectionType));
Run via ./buildscripts/resmoke.py run --suites=no_passthrough ./example.js. Note the differences in the output:
[js_test:example] mongod readConcern [js_test:example] undefined [js_test:example] mongos readConcern [js_test:example] { "level" : "local", "provenance" : "implicitDefault" } [js_test:example] mongod collectionType [js_test:example] "collection" [js_test:example] mongos collectionType [js_test:example] undefined
It's unclear to me if this is a bug or expected behavior.
- is related to
-
SERVER-88520 $queryStats' readConcern has a default value on mongos only
-
- Backlog
-