summaryrefslogtreecommitdiff
path: root/src/mongo/db/db.cpp
diff options
context:
space:
mode:
authorHenrik Edin <henrik.edin@mongodb.com>2018-03-12 11:14:15 -0400
committerHenrik Edin <henrik.edin@mongodb.com>2018-03-26 15:54:16 -0400
commitaf600c3876a26f62d8dde93bf769fc4ca3054072 (patch)
treeecef32a9b3c6c54501651168cce48093e76e9858 /src/mongo/db/db.cpp
parent2676a176759359c8614c0e37b267198259b6789f (diff)
downloadmongo-af600c3876a26f62d8dde93bf769fc4ca3054072.tar.gz
SERVER-30170 Embedded can now shutdown and re-initialize.
- ServiceContext* is now closer to be an instance context for the database. We still don't support multiple instances but I wrote the new code with this in mind. Teardown and reinitialize then becomes a matter of being able to delete and re-create the ServiceContext*. - Use the new MONGO_INITIALIZER that supports deinit/reinit to be able to re-initialize global systems that are decorations on ServiceContext. - Move creation/destruction of ServiceContext* out of MONGO_INITIALIZER. This so we can hold an exclusive lock during as much as possible of the shutdown (like how mongod does) - New ServiceContext registrer where we can link in different implementations of ServiceContext (replaces the SetGlobalEnvironment MONGO_INITIALIZER) - As a result the SetGlobalEnvironment prerequisite for MONGO_INITIALIZERs is gone. - The ServiceContext is passed to runGlobalInitializers, put in InitializationContext/DeinitializationContext so the initializers know which context they operate on.
Diffstat (limited to 'src/mongo/db/db.cpp')
-rw-r--r--src/mongo/db/db.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp
index cacb7f941a3..beb87a5d086 100644
--- a/src/mongo/db/db.cpp
+++ b/src/mongo/db/db.cpp
@@ -118,6 +118,7 @@
#include "mongo/db/server_parameters.h"
#include "mongo/db/service_context.h"
#include "mongo/db/service_context_d.h"
+#include "mongo/db/service_context_registrar.h"
#include "mongo/db/service_entry_point_mongod.h"
#include "mongo/db/session_catalog.h"
#include "mongo/db/session_killer.h"
@@ -757,8 +758,7 @@ auto makeReplicationExecutor(ServiceContext* serviceContext) {
"NetworkInterfaceASIO-Replication", nullptr, std::move(hookList)));
}
-MONGO_INITIALIZER_WITH_PREREQUISITES(CreateReplicationManager,
- ("SetGlobalEnvironment", "SSLManager", "default"))
+MONGO_INITIALIZER_WITH_PREREQUISITES(CreateReplicationManager, ("SSLManager", "default"))
(InitializerContext* context) {
auto serviceContext = getGlobalServiceContext();
repl::StorageInterface::set(serviceContext, stdx::make_unique<repl::StorageInterfaceImpl>());
@@ -958,7 +958,8 @@ int mongoDbMain(int argc, char* argv[], char** envp) {
srand(static_cast<unsigned>(curTimeMicros64()));
- Status status = mongo::runGlobalInitializers(argc, argv, envp);
+ setGlobalServiceContext(createServiceContext());
+ Status status = mongo::runGlobalInitializers(argc, argv, envp, getGlobalServiceContext());
if (!status.isOK()) {
severe(LogComponent::kControl) << "Failed global initialization: " << status;
quickExit(EXIT_FAILURE);