Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-86007

The database profiler does not record data when watching a database

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 7.0.5, 7.2.0
    • Component/s: None
    • None
    • Query Execution
    • ALL
    • Hide

      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',
          ...
        }
      ]
      
      Show
      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' , ... } ]

      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

            Assignee:
            rui.liu@mongodb.com Rui Liu
            Reporter:
            valentin.kovalenko@mongodb.com Valentin Kavalenka
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: