Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-11098

Docs for SERVER-31885: changeStream cursor is not returned on a mongos when the database does not exist.

    • Type: Icon: Task Task
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • 3.7.1, 3.6.1
    • Affects Version/s: None
    • Component/s: manual
    • Labels:
      None

      Scope of changes:

      Previously, a $changeStream could be opened on a namespace before the associated database had been created. On a replica set, this would produce a valid $changeStream cursor; on a mongoS, however, it would return an empty, closed cursor which could not be used thereafter.

      After this commit, a $changeStream can still be opened on a collection that does not yet exist provided that the database does exist. Attempting to open a $changeStream on a non-existent database results in a 'NamespaceNotFound' exception on both replica set and mongoS.

      Impact to other docs outside of this product:

      MVP:

      Resources:

      Engineering Ticket Description:

      On a replica set a changeStream cursor can be created on a collection where the database does not exist yet:

      > db.dropDatabase()
      { "ok" : 1, "operationTime" : Timestamp(1510184057, 1) }
      > db.runCommand({"aggregate":"database-does-not-exist", "pipeline":[{'$changeStream': {}}], "cursor": {}})
      {
      	"cursor" : {
      		"firstBatch" : [ ],
      		"id" : NumberLong("5437951372965323737"),
      		"ns" : "test.database-does-not-exist"
      	},
      	"ok" : 1,
      	"operationTime" : Timestamp(1510184077, 1)
      }
      

      The same operation on a mongos does not return a cursor:

      MongoDB Enterprise mongos> db.dropDatabase()
      {
      	"dropped" : "test",
      	"ok" : 1,
      	"$clusterTime" : {
      		"clusterTime" : Timestamp(1510184413, 9),
      		"signature" : {
      			"hash" : BinData(0,"lFkT1OPozsQoRVqqU/5bXxUNhng="),
      			"keyId" : NumberLong("6486191337619062789")
      		}
      	},
      	"operationTime" : Timestamp(1510184413, 9)
      }
      MongoDB Enterprise mongos> db.runCommand({"aggregate":"database-does-not-exist", "pipeline":[{'$changeStream': {}}], "cursor": {}})
      {
      	"result" : [ ],
      	"cursor" : {
      		"id" : NumberLong(0),
      		"ns" : "test.database-does-not-exist",
      		"firstBatch" : [ ]
      	},
      	"ok" : 1,
      	"$clusterTime" : {
      		"clusterTime" : Timestamp(1510184417, 1),
      		"signature" : {
      			"hash" : BinData(0,"KsuOoKtQYUkl2peKWjMv4kJHzzE="),
      			"keyId" : NumberLong("6486191337619062789")
      		}
      	},
      	"operationTime" : Timestamp(1510184417, 1)
      }
      

      This is surprising when combined with the fact that wired tiger drops databases when there are no more collections.

            Assignee:
            kay.kim@mongodb.com Kay Kim (Inactive)
            Reporter:
            kay.kim@mongodb.com Kay Kim (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              5 years, 44 weeks, 4 days ago