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

ignoreUnknownIndexOptions doesn't account for the 'weights' index field

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.1.0-rc0, 7.0.1, 6.0.10, 5.0.21
    • Affects Version/s: 6.0.6
    • Component/s: None
    • None
    • Query Execution
    • Fully Compatible
    • ALL
    • v7.0, v6.0, v5.0
    • Hide

      1. Start a MongoDB 5.0 mongod process
      2. Try to create an index that contains the field 'weights':

      db.runCommand({
          createIndexes: "test",
          indexes: [{key: { key: 1, value: 1 }, name: "index_name", weights: {key: 1, name: 1}}],
          ignoreUnknownIndexOptions: true
      })
      

      This should result in an error like this:

      MongoServerError: Error in specification { key: { key: 1, value: 1 }, name: "index_name", weights: { key: 1, name: 1 } } :: caused by :: Invalid index specification { key: { key: 1, value: 1 }, name: "index_name", weights: { key: 1, name: 1 } }; the field 'weights' can only be specified with text indexes
      
      Show
      1. Start a MongoDB 5.0 mongod process 2. Try to create an index that contains the field 'weights': db.runCommand({ createIndexes: "test", indexes: [{key: { key: 1, value: 1 }, name: "index_name", weights: {key: 1, name: 1}}], ignoreUnknownIndexOptions: true }) This should result in an error like this: MongoServerError: Error in specification { key: { key: 1, value: 1 }, name: "index_name", weights: { key: 1, name: 1 } } :: caused by :: Invalid index specification { key: { key: 1, value: 1 }, name: "index_name", weights: { key: 1, name: 1 } }; the field 'weights' can only be specified with text indexes
    • QE 2023-07-24
    • 162

      Starting in 5.0, the 'weights' field became a reserved field for text indexes. This is an issue for deployments that were upgraded from older versions to 5.0+, because they may still have non-text indexes with this 'weights' field.

      This causes mongosync processes syncing data from a source cluster with the above to error out because mongosync tries to re-create the same indexes on the destination cluster that's on MongoDB 5.0. mongosync uses the ignoreUnknownIndexOptions when creating indexes, which avoids most instances of invalid index fields but this did not work for the 'weights' field (see reproduction notes below).

            Assignee:
            alberto.massari@mongodb.com Alberto Massari
            Reporter:
            stef.wang@mongodb.com Stef Wang
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: