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

Authentication/Authorization indexes not created on initial document insertion

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 3.4.4, 3.5.7
    • 3.4.11, 3.5.8
    • Internal Code
    • None
    • Fully Compatible
    • ALL
    • v3.4
    • Platforms 2017-05-29
    • 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

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

              Dates

                Created:
                Updated:
                Resolved: