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

$listLocalSessions with missing database behaves differently on sharded clusters

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Works as Designed
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None
    • Cluster Scalability
    • ALL
    • Hide

      The script demonstrating the unexpected behavior was run against server topologies setup using the following mlaunch commands:

      • Single: mlaunch --single --hostname localhost
      • Replica Set: mlaunch --replica --priority --hostname localhost
      • Sharded Cluster: mlaunch --replica --priority --sharded 3 --hostname localhost
      Show
      The script demonstrating the unexpected behavior was run against server topologies setup using the following mlaunch commands: Single: mlaunch --single --hostname localhost Replica Set: mlaunch --replica --priority --hostname localhost Sharded Cluster: mlaunch --replica --priority --sharded 3 --hostname localhost
    • Cluster Scalability 2023-12-11

    Description

      The following script is modeled after this Drivers unified spec test and may be run with mongosh:

      var db = Mongo("mongodb://localhost:27017").getDB("database0")
      db.dropDatabase() // Initial condition: database does not exist.
       
      // db.createCollection("collection0") // See explanation below.
       
      var pipeline = [
        {'$listLocalSessions': {}},
        {'$limit': 1},
        {'$addFields': {'dummy': 'dummy field'}},
        {'$project': {'_id': 0, 'dummy': 1}},
      ]
       
      print(db.aggregate(pipeline)) // Expectation: [{dummy: 'dummy field'}]
      

      For single server topologies and replica set topologies, the $listLocalSessions command behaves as expected and the aggregation pipeline returns the single document with the dummy field. However, for sharded cluster topologies, the cursor unexpectedly returns zero documents.

      This unexpected behavior requires the database to not exist. If the database already exists, such as when the db.createCollection() command is uncommented, the cursor returns the single document with the dummy field as expected.

      This unexpected behavior seems to be present since at least server 4.2.0 and is still present in the current release.

      Attachments

        Activity

          People

            janna.golden@mongodb.com Janna Golden
            ezra.chung@mongodb.com Ezra Chung
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: