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

Renaming collection across databases with dropTarget fails with "collection already exists"

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.8.0-rc0
    • Affects Version/s: 2.7.8
    • Component/s: Storage
    • None
    • ALL

      The renameCollection command will incorrectly roll back the collection drop when renaming a collection across databases with the {dropTarget: true} option. The command will fail with the error message "collection already exists" when this happens. Affects 2.7.8.

      To reproduce:

      > use test
      switched to db test
      > db.foo.drop()
      true
      > db.foo.insert({})
      WriteResult({ "nInserted" : 1 })
      > db.getSiblingDB("test2").bar.drop()
      false
      > db.getSiblingDB("test2").bar.insert({})
      WriteResult({ "nInserted" : 1 })
      > db.adminCommand({renameCollection:"test.foo",to:"test2.bar",dropTarget:true})
      {
      	"errmsg" : "exception: collection already exists",
      	"code" : 17399,
      	"ok" : 0
      }
      

            Assignee:
            rassi J Rassi
            Reporter:
            rassi J Rassi
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: