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

improve error message on invalid text index spec



    • Major Change
    • ALL


      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)


        Issue Links



              rassi J Rassi
              rassi J Rassi
              0 Vote for this issue
              2 Start watching this issue