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

Renaming collection within same database fails if wildcard text index present

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.6.4, 2.7.2
    • Affects Version/s: 2.4.10, 2.6.0
    • Component/s: Text Search
    • None
    • ALL
    • Hide
      > db.test.insert({a:"hello"})
      WriteResult({ "nInserted" : 1 })
      > db.test.ensureIndex({"$**":"text"})
      {
      	"createdCollectionAutomatically" : false,
      	"numIndexesBefore" : 1,
      	"numIndexesAfter" : 2,
      	"ok" : 1
      }
      > db.test.renameCollection("test2")
      { "errmsg" : "exception: unknown operator: $**", "code" : 2, "ok" : 0 }
      > 
      
      Show
      > db.test.insert({a: "hello" }) WriteResult({ "nInserted" : 1 }) > db.test.ensureIndex({ "$**" : "text" }) { "createdCollectionAutomatically" : false , "numIndexesBefore" : 1, "numIndexesAfter" : 2, "ok" : 1 } > db.test.renameCollection( "test2" ) { "errmsg" : "exception: unknown operator : $**" , "code" : 2, "ok" : 0 } >

      Issue Status as of Jul 22, 2014

      ISSUE SUMMARY
      Renaming a collection within same database fails if a wildcard text index is present on the collection. The rename operation produces the following error message:

       
      { "errmsg" : "exception: unknown operator: $**", "code" : 2, "ok" : 0 } 
      

      USER IMPACT
      If a rename operation fails in this manner, the documents from the old collection will have successfully moved to the new collection. However, the new collection may be missing indexes, and operations against the old collection may crash the server. No loss of user data will occur.

      WORKAROUNDS
      To work around this issue, perform a two-step cross-database rename process that avoids renaming a collection within the same database.

      For example, suppose the following rename of a collection within the same database is desired:

      db.adminCommand({renameCollection: "database.collection1", to: "database.collection2"});
      

      Instead, run the following two operations:

      db.adminCommand({renameCollection: "database.collection1", to: "temporary_database.collection"});
      db.adminCommand({renameCollection: "temporary_database.collection", to: "database.collection2"});
      

      AFFECTED VERSIONS
      All MongoDB 2.4 production releases, and MongoDB 2.6 production releases up to 2.6.3 are affected by this issue.

      FIX VERSION
      The fix is included in the 2.6.4 production release.

      RESOLUTION DETAILS
      The logic to remove the text index from the old collection is corrected.

      Original description

      If you have a collection with an all fields FTS index and use rename collection you get an error that says.

      { "errmsg" : "exception: unknown operator: $**", "code" : 2, "ok" : 0 }

            Assignee:
            rassi J Rassi
            Reporter:
            john.page@mongodb.com John Page
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: