[SERVER-29259] Authentication/Authorization indexes not created on initial document insertion Created: 17/May/17  Updated: 30/Oct/23  Resolved: 23/May/17

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: 3.4.4, 3.5.7
Fix Version/s: 3.4.11, 3.5.8

Type: Bug Priority: Major - P3
Reporter: Spencer Jackson Assignee: Spencer Jackson
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Related
related to SERVER-33089 Unable to start queryable mongod beca... Closed
related to SERVER-29623 Fix system_authorization_indexes.js o... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v3.4
Sprint: Platforms 2017-05-29
Participants:
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));



 Comments   
Comment by Githook User [ 21/Nov/17 ]

Author:

{'name': 'Spencer Jackson', 'username': 'spencerjackson', 'email': 'spencer.jackson@mongodb.com'}

Message: SERVER-29259: Ensure creation of authorization indexes

(cherry picked from commit 763396a466b74548bcf76b23482247b668d04db5)
Branch: v3.4
https://github.com/mongodb/mongo/commit/1055dafd8d1693d48200fb492ef0912e33b60bbc

Comment by Githook User [ 23/May/17 ]

Author:

{u'username': u'spencerjackson', u'name': u'Spencer Jackson', u'email': u'spencer.jackson@mongodb.com'}

Message: SERVER-29259: Ensure creation of authorization indexes
Branch: master
https://github.com/mongodb/mongo/commit/763396a466b74548bcf76b23482247b668d04db5

Generated at Thu Feb 08 04:20:20 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.