[SERVER-79306] $listLocalSessions with missing database behaves differently on sharded clusters Created: 25/Jul/23  Updated: 28/Nov/23  Resolved: 28/Nov/23

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

Type: Bug Priority: Major - P3
Reporter: Ezra Chung Assignee: Janna Golden
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Cluster Scalability
Operating System: ALL
Steps To Reproduce:

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
Sprint: Cluster Scalability 2023-12-11
Participants:

 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.


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