[SERVER-71728] $documents not working on sharded cluster in 6.1 Created: 30/Nov/22  Updated: 27/Oct/23  Resolved: 08/Dec/22

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

Type: Bug Priority: Major - P3
Reporter: Robert Stam Assignee: Alyssa Clark
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-63811 mongos returns no results for $docume... Closed
Operating System: ALL
Steps To Reproduce:

Enterprise [direct: mongos] test> use Tests11301056
switched to db Tests11301056
Enterprise [direct: mongos] Tests11301056> db.aggregate([{ $documents : [{ X : 10 }, { X : 2 }, { X : 5 }] }])
 
Enterprise [direct: mongos]

 

Sprint: QE 2022-12-26
Participants:

 Description   

$documents is returning no documents when connected to a 6.1.0 mongos

anna.henningsen@mongodb.com discovered that this only happens if the database is empty.

 

Enterprise [direct: mongos] test> db.aggregate([{ $documents : [{ X : 10 }, { X : 2 }, { X : 5 }] }])
[ { X: 10 }, { X: 2 }, { X: 5 } ]
Enterprise [direct: mongos] test> db.dropDatabase()
{ ok: 1, dropped: 'test' }
Enterprise [direct: mongos] test> db.aggregate([{ $documents : [{ X : 10 }, { X : 2 }, { X : 5 }] }]) 
Enterprise [direct: mongos] test>



 Comments   
Comment by Alyssa Clark [ 24/Jan/23 ]

This was fixed on 6.0.3, not 6.0.2. Similarly, this was an issue in 6.1.0 but was fixed in a later 6.1 patch release. Since 6.0.2 is a patch release, the fix will not be backported.

6.0.2:

 

MongoDB Enterprise mongos> db.version()
6.0.2
MongoDB Enterprise mongos> use test
switched to db test
MongoDB Enterprise mongos> db.dropDatabase()
{
    "ok" : 1,
    "$clusterTime" : {
        "clusterTime" : Timestamp(1674592837, 1),
        "signature" : {
            "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
            "keyId" : NumberLong(0)
        }
    },
    "operationTime" : Timestamp(1674592837, 1)
}
MongoDB Enterprise mongos> db.aggregate([{ $documents : [{ X : 10 }, { X : 2 }, { X : 5 }] }]) 
MongoDB Enterprise mongos>

6.0.3:

 

 

MongoDB Enterprise mongos> db.version()
6.0.3
MongoDB Enterprise mongos> use test
switched to db test
MongoDB Enterprise mongos> db.dropDatabase()
{
    "ok" : 1,
    "$clusterTime" : {
        "clusterTime" : Timestamp(1674594149, 1),
        "signature" : {
            "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
            "keyId" : NumberLong(0)
        }
    },
    "operationTime" : Timestamp(1674594149, 1)
}
MongoDB Enterprise mongos> db.aggregate([{ $documents : [{ X : 10 }, { X : 2 }, { X : 5 }] }])
{ "X" : 10 }
{ "X" : 2 }
{ "X" : 5 }
MongoDB Enterprise mongos> 

 

 

Comment by Dmitry Lukyanov (Inactive) [ 24/Jan/23 ]

We see this issue again (with server 6.0.2):

Enterprise [direct: mongos] test> use test
already on db test
Enterprise [direct: mongos] test> db.dropDatabase()
{ ok: 1, dropped: 'test' }
Enterprise [direct: mongos] test> db.aggregate([{ $documents : [{ X : 10 }, { X : 2 }, { X : 5 }] }])
 
Enterprise [direct: mongos] test> db.test.insertOne({ _id : 1 })
{ acknowledged: true, insertedId: 1 }
Enterprise [direct: mongos] test> db.aggregate([{ $documents : [{ X : 10 }, { X : 2 }, { X : 5 }] }])
[ { X: 10 }, { X: 2 }, { X: 5 } ]
Enterprise [direct: mongos] test>

Server details:

Enterprise [direct: mongos] test> db.version()
6.0.2
Enterprise [direct: mongos] test> sh.status()
Warning: MongoshWarning: [SHAPI-10003] You are not connected to a mongos. This command may not work as expected.
shardingVersion
{
  _id: 1,
  minCompatibleVersion: 5,
  currentVersion: 6,
  clusterId: ObjectId("63d032d0ab474b70b1cd5aec")
}
---
shards
[
  {
    _id: 'shard01',
    host: 'shard01/localhost:27018,localhost:27019,localhost:27020',
    state: 1,
    topologyTime: Timestamp({ t: 1674588891, i: 11 })
  },
  {
    _id: 'shard02',
    host: 'shard02/localhost:27021,localhost:27022,localhost:27023',
    state: 1,
    topologyTime: Timestamp({ t: 1674588891, i: 17 })
  }
]
---
active mongoses
[ { '6.0.2': 1 } ]
---
autosplit
{ 'Currently enabled': 'yes' }
---
balancer
{
  'Currently running': 'no',
  'Currently enabled': 'yes',
  'Failed balancer rounds in last 5 attempts': 0,
  'Migration Results for the last 24 hours': { '31': 'Success' }
}
---
databases
[
  {
    database: { _id: 'config', primary: 'config', partitioned: true },
    collections: {
      'config.system.sessions': {
        shardKey: { _id: 1 },
        unique: false,
        balancing: true,
        chunkMetadata: [
          { shard: 'shard01', nChunks: 993 },
          { shard: 'shard02', nChunks: 31 }
        ],
        chunks: [
          'too many chunks to print, use verbose if you want to force print'
        ],
        tags: []
      }
    }
  },
  {
    database: {
      _id: 'test',
      primary: 'shard01',
      partitioned: false,
      version: {
        uuid: new UUID("e3a8ab91-fa67-4695-8732-de189a5d2a84"),
        timestamp: Timestamp({ t: 1674588968, i: 1 }),
        lastMod: 1
      }
    },
    collections: {}
  }
]
Enterprise [direct: mongos] test> 

Has the fix been backported?

The same behavior we see with rapid env. The server version 6.1.0:

db version v6.1.0
Build Info: {
  "version": "6.1.0",
  "gitVersion": "0ca11aca38c75d3c8fb5bac5bd103b950718a896",
    "modules": [
      "enterprise"
    ],
    "allocator": "tcmalloc",
    "environment": {
    "distmod": "windows",
    "distarch": "x86_64",
    "target_arch": "x86_64"
  }
} 

Comment by Dmitry Lukyanov (Inactive) [ 23/Dec/22 ]

cc: alyssa.wagenmaker@mongodb.com 

Comment by Dmitry Lukyanov (Inactive) [ 23/Dec/22 ]

Recently we've noticed this issue once again in this test. See this patch for details. However I wasn't able to reproduce this on my windows machine.

MongoDB Enterprise mongos> db.aggregate([{ $documents : [{ X : 10 }, { X : 2 }, { X : 5 }] }])
{ "X" : 10 }
{ "X" : 2 }
{ "X" : 5 }
MongoDB Enterprise mongos> db.dropDatabase()
{
        "ok" : 1,
        "$clusterTime" : {
                "clusterTime" : Timestamp(1671755091, 1),
                "signature" : {
                        "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                        "keyId" : NumberLong(0)
                }
        },
        "operationTime" : Timestamp(1671755091, 1)
}
MongoDB Enterprise mongos> db.aggregate([{ $documents : [{ X : 10 }, { X : 2 }, { X : 5 }] }])
{ "X" : 10 }
{ "X" : 2 }
{ "X" : 5 }
MongoDB Enterprise mongos> db.version()
6.3.0-alpha-743-g5732e9c 

cc: robert@mongodb.com

Comment by Alyssa Clark [ 08/Dec/22 ]

I reproduced the issue on 6.1.0, but it appears to have been fixed since then on the v6.1 branch:

[direct: mongos] test> db.version()
6.1.0-rc3-100-g3b45a1f
[direct: mongos] test> db.dropDatabase()
{ ok: 1, dropped: 'test' }
[direct: mongos] test> db.aggregate([{ $documents : [{ X : 10 }, { X : 2 }, { X : 5 }] }])
[ { X: 10 }, { X: 2 }, { X: 5 } ]
[direct: mongos] test>

It also is working on earlier versions (I checked on the current v6.0 branch) as well as on master. Given that, I'll close this ticket.

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