#8146 Index error with mongo 3.4

v1.7.0
closed
None
General
nobody
2017-06-27
2017-02-28
No

Running paster setup-app command with mongo 3.4 gives:

  File "/allura/Allura/allura/websetup/__init__.py", line 38, in setup_app
    bootstrap.bootstrap(command, conf, vars)
  File "/allura/Allura/allura/websetup/bootstrap.py", line 103, in bootstrap
    index.run([''])
  File "/allura-data/virtualenv/local/lib/python2.7/site-packages/paste/script/command.py", line 238, in run
    result = self.command()
  File "/allura/Allura/allura/command/show_models.py", line 240, in command
    self._update_indexes(db[name], indexes)
  File "/allura/Allura/allura/command/show_models.py", line 292, in _update_indexes
    collection.ensure_index(idx.index_spec, **idx.index_options)
  File "/allura-data/virtualenv/local/lib/python2.7/site-packages/pymongo/collection.py", line 1186, in ensure_index
    return self.create_index(key_or_list, cache_for, **kwargs)
  File "/allura-data/virtualenv/local/lib/python2.7/site-packages/pymongo/collection.py", line 1069, in create_index
    indexes=[index])
  File "/allura-data/virtualenv/local/lib/python2.7/site-packages/pymongo/database.py", line 439, in command
    uuid_subtype, compile_re, **kwargs)[0]
  File "/allura-data/virtualenv/local/lib/python2.7/site-packages/pymongo/database.py", line 345, in _command
    msg, allowable_errors)
  File "/allura-data/virtualenv/local/lib/python2.7/site-packages/pymongo/helpers.py", line 182, in _check_command_response
    raise OperationFailure(msg % errmsg, code, response)
OperationFailure: command SON([('createIndexes', u'basestats'), ('indexes', [{'sparse': False, 'unique': True, 'name': u'_id_1', 'key': SON([('_id', 1)])}])]) on namespace allura.$cmd failed: The field 'sparse' is not valid for an _id index specification. Specification: { ns: "allura.basestats", v: 1, sparse: false, unique: true, name: "_id_1", key: { _id: 1 } }

https://docs.mongodb.com/manual/release-notes/3.4-compatibility/#stricter-validation-of-index-specifications doesn't specifically mention sparse _id, but looks like that is the change that is causing this.

So I guess we need to omit sparse: False on _id fields, or any time it's false.

Discussion

  • Dave Brondsema

    Dave Brondsema - 2017-03-13
    • status: open --> review
    • assigned_to: Dave Brondsema
     
  • Dave Brondsema

    Dave Brondsema - 2017-03-13

    Fix on branch db/8146

     
  • Kenton Taylor

    Kenton Taylor - 2017-03-15

    Merged.

     
  • Kenton Taylor

    Kenton Taylor - 2017-03-15
    • status: review --> closed
     
  • Dave Brondsema

    Dave Brondsema - 2017-06-27
    • Milestone: unreleased --> v1.7.0
     

Log in to post a comment.