[SERVER-14027] Renaming collection within same database fails if wildcard text index present Created: 22/May/14  Updated: 11/Jul/16  Resolved: 13/Jun/14

Status: Closed
Project: Core Server
Component/s: Text Search
Affects Version/s: 2.4.10, 2.6.0
Fix Version/s: 2.6.4, 2.7.2

Type: Bug Priority: Major - P3
Reporter: John Page Assignee: J Rassi
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Operating System: ALL
Backport Completed:
Steps To Reproduce:

> 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 }
> 

Participants:

 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 }

 Comments   
Comment by Githook User [ 16/Jun/14 ]

Author:

{u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: SERVER-14027 Test renaming collection containing wildcard text index

(cherry picked from commit 969e42a89697d0cdfbb7e615f07d94745982b607)
Branch: v2.6
https://github.com/mongodb/mongo/commit/cd5850a2e9776922cf3d94b4e15bcb54737ed58a

Comment by Githook User [ 16/Jun/14 ]

Author:

{u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: SERVER-14027 renameCollection don't pass full spec to deleteObjects

If a collection being renamed has an index spec object which contains
a field prefixed by a dollar sign, deleteObjects will refuse to remove
the old spec object. Uniquely identify the index in system.indexes by

{ns: ..., name: ...}

.
Branch: v2.6
https://github.com/mongodb/mongo/commit/7db999a868c925f86c06a15b3f47a45e892287ed

Comment by Githook User [ 16/Jun/14 ]

Author:

{u'username': u'ehershey', u'name': u'Ernie Hershey', u'email': u'ernie.hershey@10gen.com'}

Message: Revert "SERVER-14027 renameCollection don't pass full spec to deleteObjects"

This reverts commit 3a3922cefcbf746f85789c86f108c84d9bf26d9e.
Branch: v2.6
https://github.com/mongodb/mongo/commit/9d5cfbd40af043095ea7c4787a224aeff1df728c

Comment by Githook User [ 16/Jun/14 ]

Author:

{u'username': u'ehershey', u'name': u'Ernie Hershey', u'email': u'ernie.hershey@10gen.com'}

Message: Revert "SERVER-14027 Test renaming collection containing wildcard text index"

This reverts commit 505b3feffbbb1ab1da27cae77cd76296df13b9d1.
Branch: v2.6
https://github.com/mongodb/mongo/commit/2ad6b4aa43ad052ae28502e7be7112eab7de5638

Comment by Githook User [ 16/Jun/14 ]

Author:

{u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: SERVER-14027 Test renaming collection containing wildcard text index

(cherry picked from commit 969e42a89697d0cdfbb7e615f07d94745982b607)
Branch: v2.6
https://github.com/mongodb/mongo/commit/505b3feffbbb1ab1da27cae77cd76296df13b9d1

Comment by Githook User [ 16/Jun/14 ]

Author:

{u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: SERVER-14027 renameCollection don't pass full spec to deleteObjects

If a collection being renamed has an index spec object which contains
a field prefixed by a dollar sign, deleteObjects will refuse to remove
the old spec object. Uniquely identify the index in system.indexes by

{ns: ..., name: ...}

.
Branch: v2.6
https://github.com/mongodb/mongo/commit/3a3922cefcbf746f85789c86f108c84d9bf26d9e

Comment by Githook User [ 13/Jun/14 ]

Author:

{u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: SERVER-14027 Test renaming collection containing wildcard text index
Branch: master
https://github.com/mongodb/mongo/commit/969e42a89697d0cdfbb7e615f07d94745982b607

Comment by J Rassi [ 12/Jun/14 ]

Fixed in master for 2.7.2 by ebc62807f6ba7b1ba13a2c50efd6d0ec1598fc36. Needs tests added and fix backported.

Generated at Thu Feb 08 03:33:37 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.