[SERVER-13265] Race condition in mongorestore when setting the globalAuthorizationManager Created: 18/Mar/14  Updated: 11/Jul/16  Resolved: 19/Mar/14

Status: Closed
Project: Core Server
Component/s: Security, Tools
Affects Version/s: 2.6.0-rc1
Fix Version/s: 2.6.0-rc2

Type: Bug Priority: Minor - P4
Reporter: Kaloian Manassiev Assignee: Spencer Brody (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:
Linked BF Score: 0

 Description   

Occasionally mongorestore fails to start with the following call stack:

sh27974| 2014-03-14T15:46:07.210-0400 [journal] Fatal Assertion 16842
sh27974| 2014-03-14T15:46:07.210-0400 jstests/dur/data/empty.bson
sh27974| 2014-03-14T15:46:07.210-0400 	going into namespace [test.empty]
sh27974| 2014-03-14T15:46:07.213-0400 [journal] 0x10068edeb 0x100648712 0x10063827e 0x1000a33cc 0x10010a5f2 0x1001d2502 0x1006c31f5 0x7fff8c9257a2 0x7fff8c9121e1 
sh27974|  0   mongorestore                        0x000000010068edeb mongo::printStackTrace(std::ostream&)   43
sh27974|  1   mongorestore                        0x0000000100648712 mongo::logContext(char const*)   114
sh27974|  2   mongorestore                        0x000000010063827e mongo::fassertFailed(int)   110
sh27974|  3   mongorestore                        0x00000001000a33cc mongo::getGlobalAuthorizationManager()   28
sh27974|  4   mongorestore                        0x000000010010a5f2 mongo::Client::initThread(char const*, mongo::AbstractMessagingPort*)   640
sh27974|  5   mongorestore                        0x00000001001d2502 mongo::dur::durThread()   34
sh27974|  6   mongorestore                        0x00000001006c31f5 thread_proxy   229
sh27974|  7   libsystem_c.dylib                   0x00007fff8c9257a2 _pthread_start   327
sh27974|  8   libsystem_c.dylib                   0x00007fff8c9121e1 thread_start   13
sh27974| 2014-03-14T15:46:07.214-0400 [journal] 
sh27974| 
sh27974| ***aborting after fassert() failure
sh27974| 

This is because when the durThread starts it calls client::initThread, which calls getGlobalAuthorizationManager(), which has an fassert that the globalAuthorizationManager is set. In the run method of mongorestore, however, we briefly clear the globalAuthorizationManager to set it to a real implementation instead of a Mock. This leaves a small window where the globalAuthorizationManager is unset, which can trigger the fassert in getGlobalAuthorizationManager depending on the timing of the dur thread starting up.

Fix is to move the setting of the globalAuthorizationManager out of the Restore class' doRun method and into its constructor, which will run before the durThread is started.



 Comments   
Comment by Githook User [ 19/Mar/14 ]

Author:

{u'username': u'stbrody', u'name': u'Spencer T Brody', u'email': u'spencer@mongodb.com'}

Message: SERVER-13265 Fix race condition in mongorestore startup
(cherry picked from commit 47ce3aebb48d9b9191584e3173774e29a0a3808c)
Branch: v2.6
https://github.com/mongodb/mongo/commit/21426b3b8109fafb7fae997021cbd0357c968111

Comment by Githook User [ 19/Mar/14 ]

Author:

{u'username': u'stbrody', u'name': u'Spencer T Brody', u'email': u'spencer@mongodb.com'}

Message: SERVER-13265 Fix race condition in mongorestore startup
Branch: master
https://github.com/mongodb/mongo/commit/47ce3aebb48d9b9191584e3173774e29a0a3808c

Generated at Thu Feb 08 03:31:10 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.