[SERVER-8921] improve error message on invalid text index spec Created: 09/Mar/13  Updated: 11/Jul/16  Resolved: 12/Mar/13

Status: Closed
Project: Core Server
Component/s: Replication, Text Search
Affects Version/s: 2.4.0-rc2
Fix Version/s: 2.4.0-rc3, 2.5.0

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

Issue Links:
Related
related to SERVER-8751 Downgrading 2.4=>2.2 without dropping... Closed
Backwards Compatibility: Major Change
Operating System: ALL
Participants:

 Description   

I believe the root cause is that the initial sync code, when building indexes, constructs an IndexSpec object on the sync'd spec without looking up the plugin and calling adjustIndexSpec.

This issue manifests whenever a 2.4 instance is performing an initial sync from an instance that has a false "text" index. A false "text" index can exist on 2.2 if the user runs ensureIndex({foo:"text"}), and a false "text" index can exist on 2.4 if the user upgrades a 2.2 instance that has a false "text" index.

The primary concern here is that the error message gives the user no insight into how he/she caused the problem (once the user figures this out, the solution is simple: drop the offending index and retry the initial sync).

To reproduce:

  1. Start 2.2.3 instance
  2. rs.initiate()
  3. db.foo.ensureIndex({a:"text"})
  4. Start 2.4.0-rc2 instance
  5. Add 2.4.0-rc2 instance to replica set

Results in:

Fri Mar  8 19:28:36.980 [rsSync] replSet initial sync drop all databases
Fri Mar  8 19:28:36.980 [rsSync] dropAllDatabasesExceptLocal 1
Fri Mar  8 19:28:36.980 [rsSync] replSet initial sync clone all databases
Fri Mar  8 19:28:36.981 [rsSync] replSet initial sync cloning db: test
Fri Mar  8 19:28:36.983 [rsSync] replSet initial sync exception: 10065 invalid parameter: expected an object () 9 attempts remaining

The only information gleaned from the log is that some error occurred while cloning the database test. Turning up logging all the way yields no additional information.

The expected behavior is that the initial sync succeeds, and the instance gets a true text index; this is what happens if you create a text index on the primary during steady-state replication.

Evidence from debugging shows that the error is that the FTSSpec constructor is unable to find the field weights in the spec:

--- fts_spec.cpp ---
47                 BSONObjIterator i( indexInfo["weights"].Obj() );

and, up the call stack, the IndexSpec constructor is being called from Cloner::go():

--- cloner.cpp ---
414                 details.spec = IndexSpec(idxEntry["key"].Obj().copy(), idxEntry.copy());

(adjustIndexSpec will convert an index spec from having key {foo: "text"} to having key {_fts: "text", _ftsx: 1}, and also adds additional fields, e.g. weights, textIndexVersion)



 Comments   
Comment by auto [ 12/Mar/13 ]

Author:

{u'date': u'2013-03-12T14:47:08Z', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: SERVER-8921 Change error condition for invalid text index spec
Branch: v2.4
https://github.com/mongodb/mongo/commit/bb2313f4204203b8289546151d475f5d3b247511

Comment by auto [ 12/Mar/13 ]

Author:

{u'date': u'2013-03-12T14:47:08Z', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: SERVER-8921 Change error condition for invalid text index spec
Branch: master
https://github.com/mongodb/mongo/commit/2bc9d4ee47db6b39a7509e080b5b457563272db5

Comment by auto [ 12/Mar/13 ]

Author:

{u'date': u'2013-03-12T14:29:09Z', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: SERVER-8921 Improve error message for invalid text index spec
Branch: v2.4
https://github.com/mongodb/mongo/commit/1b84109f9c0fb976d67de4a837391fbbfbb6659a

Comment by auto [ 12/Mar/13 ]

Author:

{u'date': u'2013-03-12T14:29:09Z', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: SERVER-8921 Improve error message for invalid text index spec
Branch: master
https://github.com/mongodb/mongo/commit/34f01531077d1843c1277303a5ce94dcb8bdba63

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