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

Authentication/Authorization indexes not created on initial document insertion

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.4.11, 3.5.8
    • Affects Version/s: 3.4.4, 3.5.7
    • Component/s: Internal Code
    • None
    • Fully Compatible
    • ALL
    • v3.4
    • Platforms 2017-05-29
    • 0

      After creating a user on 3.2, running getIndexes shows indexes created on admin.system.users.

      > db.system.users.getIndexes()
      [ ]
      > db.createUser({user: "sajack", pwd: "sajack", roles: []})
      Successfully added user: { "user" : "sajack", "roles" : [ ] }
      > db.system.users.getIndexes()
      [
              {
                      "v" : 1,
                      "key" : {
                              "_id" : 1
                      },
                      "name" : "_id_",
                      "ns" : "admin.system.users"
              },
              {
                      "v" : 1,
                      "unique" : true,
                      "key" : {
                              "user" : 1,
                              "db" : 1
                      },
                      "name" : "user_1_db_1",
                      "ns" : "admin.system.users"
              }
      ]
      

      Performing the same operation on 3.4 does not result in an index being created:

      > use admin
      switched to db admin
      > db.createUser({user: "sajack", pwd: "sajack", roles: []})
      Successfully added user: { "user" : "sajack", "roles" : [ ] }
      > db.system.users.getIndexes()
      [
              {
                      "v" : 2,
                      "key" : {
                              "_id" : 1
                      },
                      "name" : "_id_",
                      "ns" : "admin.system.users"
              }
      ]
      

      This could cause authentication to be slow.

      This seems to be caused in auth_index_d.cpp. This call requires the index version be explicitly set to 2:

                collection->getIndexCatalog()->createIndexOnEmptyCollection(                                
                    opCtx,                                                                                  
                    BSON("name" << v3SystemUsersIndexName << "ns" << collection->ns().ns() << "key"         
                                << v3SystemUsersKeyPattern                                                  
                                << "unique"                                                                 
                                << true));
      

            Assignee:
            spencer.jackson@mongodb.com Spencer Jackson
            Reporter:
            spencer.jackson@mongodb.com Spencer Jackson
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: