[SERVER-86007] The database profiler does not record data when watching a database Created: 31/Jan/24  Updated: 06/Feb/24

Status: Backlog
Project: Core Server
Component/s: None
Affects Version/s: 7.0.5, 7.2.0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Valentin Kavalenka Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Execution
Operating System: ALL
Steps To Reproduce:

Run the following code in mongosh

use myDb;
const session = db.getMongo().startSession();
db = session.getDatabase(db.getName());
db.runCommand({ profile: 0 });
db.dropDatabase();
{
    db.runCommand({ profile: 2 })
    const watchCursor = db.watch();
    watchCursor.tryNext();
    db.myColl.insertOne({});
    db.system.profile.find({}, {op: 1, ns: 1, command: 1});
}
db.runCommand({ profile: 0 });
db.dropDatabase();
session.endSession();

and see that only the insert into myDb.myColl is recorded despite the profiling level being 2:

[
  {
    op: 'insert',
    ns: 'myDb.myColl',
    ...
  }
]

If we do db.myColl.watch() instead of db.watch() in the scenario specified above

use myDb;
const session = db.getMongo().startSession();
db = session.getDatabase(db.getName());
db.runCommand({ profile: 0 });
db.dropDatabase();
{
    db.runCommand({ profile: 2 })
    const watchCursor = db.myColl.watch();
    watchCursor.tryNext();
    db.myColl.insertOne({});
    db.system.profile.find({}, {op: 1, ns: 1, command: 1});
}
db.runCommand({ profile: 0 });
db.dropDatabase();
session.endSession();

then we can see the corresponding getmore commands in system.profile:

[
  {
    op: 'getmore',
    ns: 'myDb.myColl',
    ...
  },
  {
    op: 'getmore',
    ns: 'myDb.myColl',
    ...
  },
  {
    op: 'insert',
    ns: 'myDb.myColl',
    ...
  }
]

Participants:

 Description   

I noticed at first when using the Java driver, then when using mongosh, that the database profiler does not record data about getmore commands issued when I am watching a database, but does record those commands when I am watching a collection.

I observed this problem with the following setup:

  • OS: macOS
  • ISA: ARM 64
  • MongoDB: tried both 7.0.5-ent, 7.2.0-ent
  • deployment: P-S-S replica set
  • storage engine: tried both wiredTiger, inMemory

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