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

Clear database state when dropping last collection

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Storage Execution
    • Execution Team 2024-02-19, Execution Team 2024-03-04, Execution Team 2024-03-18

      > db.getSiblingDB('mydb').createCollection('foo')
      > db.getSiblingDB('mydb').foo.drop()
      > db.getSiblingDB('Mydb').createCollection('foo')
      MongoServerError: db already exists with different case already have: [mydb] trying to create [Mydb]
      

      ^^ The above happens even in replica sets (i.e., unsharded clusters). Happens in the last 4.2 version as well as 7.0.5.

      Per matt.kneiser@mongodb.com, it looks like the reason is:

      It looks like the DatabaseHolderImpl/DBsIndex, requires an explicit dropDb() call to unregister the namespace. Otherwise, we keep state around in memory that a database with "mydb" exists.

      (Slack thread)

      Ideas:

      • The last collection drop should probably clear out the DB state.
      • Should that mean we get an oplog dropDatabase entry (and change event), too?

      Additional context: Mongosync can’t do `dropDatabase` commands—even in response to events of that name—because there’s no UUID.

            Assignee:
            henrik.edin@mongodb.com Henrik Edin
            Reporter:
            felipe.gasper@mongodb.com Felipe Gasper
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: