[SERVER-83964] Query stats not collected on mongos if database does not exist Created: 07/Dec/23  Updated: 20/Dec/23  Resolved: 20/Dec/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.3.0-rc0

Type: Bug Priority: Major - P3
Reporter: Charlie Swanson Assignee: Charlie Swanson
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-85096 TRACKING: M3 Correctness Tickets Closed
Related
related to SERVER-84316 Query test suite(s) with shared shard... Backlog
Assigned Teams:
Query Integration
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

This test doesn't record any query stats for the "anything" namespace:

const st = new ShardingTest({
    shards: 2,
    mongos: 1,
    config: 1,
    mongosOptions: {setParameter: {internalQueryStatsRateLimit: -1}}
});
 
let db = st.getDB("test");
let adminDb = db.getSiblingDB("admin");
 
assert.eq(null, db.anything.findOne());
jsTestLog(adminDb.aggregate([{$queryStats: {}}]).toArray());
st.stop();

This corresponding test for a mongod does indeed return a query shape for "anything":

const mongod = MongoRunner.runMongod({setParameter: {internalQueryStatsRateLimit: -1}});
 
let db = mongod.getDB("test");
let adminDb = db.getSiblingDB("admin");
 
assert.eq(null, db.anything.findOne());
jsTestLog(adminDb.aggregate([{$queryStats: {}}]).toArray());
mongod.stop();

Participants:

 Description   

On a mongod these would be collected with a "nonExistent" namespace. Seems like we early-exit too early in this case on mongos.



 Comments   
Comment by Githook User [ 19/Dec/23 ]

Author:

{'name': 'Charlie Swanson', 'email': 'charlie.swanson@mongodb.com', 'username': 'cswanson310'}

Message: SERVER-83964 Collect query stats even if database does not exist

There is a special case for this path which just needed to be updated.
This patch also refactors some testing to cut down on redundant
starting/stopping of ShardingTests.

GitOrigin-RevId: 00f12b3ac6d1a580a5f32113e9e91806e74b0bd5
Branch: master
https://github.com/mongodb/mongo/commit/d26995615459164a7f600667567c8366f03bff66

Generated at Thu Feb 08 06:53:39 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.