Operational Defect Database

BugZero found this defect 103 days ago.

MongoDB | 2568564

Investigate whether differences in query stats keys between mongod and mongos are expected

Last update date:

3/14/2024

Affected products:

MongoDB Server

Affected releases:

No affected releases provided.

Fixed releases:

No fixed releases provided.

Description:

Info

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.

Top User Comments


Steps to Reproduce


Additional Resources / Links

Share:

BugZero® Risk Score

What's this?

Coming soon

Status

Closed

Learn More

Search:

...