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

_id is null when upserting into local system.users collection

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.2.0, 2.2.1
    • Component/s: Storage, Write Ops
    • None
    • Storage Execution
    • OS X

      An upsert into the "local.system.users" collection creates documents with no _id. Since there is an index on _id, this will create an index key of

      { "_id" : null}

      for the first upserted user document. So upserting another user document will fail with the following error.

      E11000 duplicate key error index: local.system.users.$id dup key: { : null }

      This happens only if local system.users is empty or there are no documents with _id set. If there is at least one document with _id set then it will work fine.

      Since pymongo adds users using upserts, this will make pymongo fail when adding more than one local user

      To replicate:
      1- start a fresh 2.2.0 mongod server(nuke dbpath)

      1. mongod --dbpath /data/db --port 27017

      2- mongo into server and use local db

      1. mongo

      3- upsert a user document into system.users

      1. db.system.users.update( {"user":"abdul"}

        ,

        {"user":"abdul", "pwd":"xxxxxxxxx"}

        , true);

      4- Note that inserted document does not have an _id

      1. db.system.users.find()

      5- Insert another document

      RESULT:

      E11000 duplicate key error index: local.system.users.$id dup key: { : null }

            Assignee:
            backlog-server-execution [DO NOT USE] Backlog - Storage Execution Team
            Reporter:
            abdul Abdul Alkhatib
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: