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

Renaming collection within same database fails if wildcard text index present

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 2.4.10, 2.6.0
    • Fix Version/s: 2.6.4, 2.7.2
    • Component/s: Text Search
    • Labels:
      None
    • Operating System:
      ALL
    • Backport Completed:
    • Steps To Reproduce:
      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 } >

      Description

      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 }

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: