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

Authentication/Authorization indexes not created on initial document insertion

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 3.4.4, 3.5.7
    • Fix Version/s: 3.4.11, 3.5.8
    • Component/s: Internal Code
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v3.4
    • Sprint:
      Platforms 2017-05-29
    • Linked BF Score:
      0

      Description

      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));
      

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: