-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Cluster Scalability
-
ALL
-
-
Cluster Scalability 2023-12-11
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.