diff options
author | Billy Donahue <billy.donahue@mongodb.com> | 2020-04-26 07:05:39 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-12-08 22:45:08 +0000 |
commit | 7c51aca7fd085ead0ae3e19d967ff1abf111d13a (patch) | |
tree | becfe057d3dbbb88b02ad628fb1a95a30adf686c /src/mongo/db | |
parent | 987484b4aa34deea1db7d70228989b83448a24e8 (diff) | |
download | mongo-7c51aca7fd085ead0ae3e19d967ff1abf111d13a.tar.gz |
SERVER-40811 make initializers throwy
- Consolidate init-related headers (just init.h and initializer.h)
- Factor out a separate DependencyGraph component
- Remove MONGO_DEFAULT_PREREQUISITES, MONGO_NO_PREREQUISITES, MONGO_NO_DEPENDENTS.
- Document the role of the "default" initializer.
Diffstat (limited to 'src/mongo/db')
54 files changed, 59 insertions, 151 deletions
diff --git a/src/mongo/db/auth/authorization_manager_impl.cpp b/src/mongo/db/auth/authorization_manager_impl.cpp index 50401c7809a..729df9178a7 100644 --- a/src/mongo/db/auth/authorization_manager_impl.cpp +++ b/src/mongo/db/auth/authorization_manager_impl.cpp @@ -89,10 +89,8 @@ MONGO_INITIALIZER_GENERAL(SetupInternalSecurityUser, } internalSecurity.user = user; - - return Status::OK(); } catch (...) { - return exceptionToStatus(); + uassertStatusOK(exceptionToStatus()); } class PinnedUserSetParameter { diff --git a/src/mongo/db/auth/builtin_roles.cpp b/src/mongo/db/auth/builtin_roles.cpp index 622ba2f5a87..037f7765c35 100644 --- a/src/mongo/db/auth/builtin_roles.cpp +++ b/src/mongo/db/auth/builtin_roles.cpp @@ -259,8 +259,6 @@ MONGO_INITIALIZER(AuthorizationBuiltinRoles)(InitializerContext* context) { << ActionType::splitVector << ActionType::refineCollectionShardKey << ActionType::reshardCollection; - - return Status::OK(); } // clang-format on diff --git a/src/mongo/db/auth/sasl_commands.cpp b/src/mongo/db/auth/sasl_commands.cpp index d352eeeb082..e89dda82f7c 100644 --- a/src/mongo/db/auth/sasl_commands.cpp +++ b/src/mongo/db/auth/sasl_commands.cpp @@ -433,8 +433,6 @@ MONGO_INITIALIZER(PreSaslCommands) (InitializerContext*) { if (!sequenceContains(saslGlobalParams.authenticationMechanisms, kX509AuthMechanism)) disableAuthMechanism(kX509AuthMechanism); - - return Status::OK(); } } // namespace diff --git a/src/mongo/db/auth/sasl_options.cpp b/src/mongo/db/auth/sasl_options.cpp index d390ad99524..63414acc3a1 100644 --- a/src/mongo/db/auth/sasl_options.cpp +++ b/src/mongo/db/auth/sasl_options.cpp @@ -52,7 +52,6 @@ namespace { MONGO_INITIALIZER_WITH_PREREQUISITES(InitSpeculativeCounters, ("EndStartupOptionStorage")) (InitializerContext*) { authCounter.initializeMechanismMap(saslGlobalParams.authenticationMechanisms); - return Status::OK(); } } // namespace diff --git a/src/mongo/db/auth/sasl_options_init.cpp b/src/mongo/db/auth/sasl_options_init.cpp index 21050612cbd..6d22544af6d 100644 --- a/src/mongo/db/auth/sasl_options_init.cpp +++ b/src/mongo/db/auth/sasl_options_init.cpp @@ -89,7 +89,7 @@ Status storeSASLOptions(const moe::Environment& params) { } MONGO_INITIALIZER_GENERAL(StoreSASLOptions, ("CoreOptions_Store"), ("EndStartupOptionStorage")) -(InitializerContext* const context) { - return storeSASLOptions(moe::startupOptionsParsed); +(InitializerContext*) { + uassertStatusOK(storeSASLOptions(moe::startupOptionsParsed)); } } // namespace mongo diff --git a/src/mongo/db/commands.h b/src/mongo/db/commands.h index 9043b84612a..140d7bccee4 100644 --- a/src/mongo/db/commands.h +++ b/src/mongo/db/commands.h @@ -1127,19 +1127,19 @@ private: CommandRegistry* globalCommandRegistry(); /** - * Creates a test command object of type CmdType if test commands are enabled for this process. - * Prefer this syntax to using MONGO_INITIALIZER directly. - * The created Command object is "leaked" intentionally, since it will register itself. + * Creates a test command object of type CmdType if test commands are enabled + * for this process. Prefer this syntax to using MONGO_INITIALIZER directly. + * The created Command object is "leaked" intentionally, since it will register + * itself. + * + * The command objects will be created after the "default" initializer, and all + * startup option processing happens prior to "default" (see base/init.h). */ -#define MONGO_REGISTER_TEST_COMMAND(CmdType) \ - MONGO_INITIALIZER_WITH_PREREQUISITES( \ - RegisterTestCommand_##CmdType, \ - (::mongo::defaultInitializerName().c_str(), "EndStartupOptionHandling")) \ - (InitializerContext*) { \ - if (getTestCommandsEnabled()) { \ - new CmdType(); \ - } \ - return Status::OK(); \ +#define MONGO_REGISTER_TEST_COMMAND(CmdType) \ + MONGO_INITIALIZER(RegisterTestCommand_##CmdType)(InitializerContext*) { \ + if (getTestCommandsEnabled()) { \ + new CmdType(); \ + } \ } } // namespace mongo diff --git a/src/mongo/db/commands/fsync.cpp b/src/mongo/db/commands/fsync.cpp index cc50ca5bf3a..5573e813b7b 100644 --- a/src/mongo/db/commands/fsync.cpp +++ b/src/mongo/db/commands/fsync.cpp @@ -448,7 +448,6 @@ void FSyncLockThread::run() { MONGO_INITIALIZER(fsyncLockedForWriting)(InitializerContext* context) { setLockedForWritingImpl([]() { return fsyncCmd.fsyncLocked(); }); - return Status::OK(); } } // namespace diff --git a/src/mongo/db/commands/index_filter_commands.cpp b/src/mongo/db/commands/index_filter_commands.cpp index ec7529c608e..c9a82127980 100644 --- a/src/mongo/db/commands/index_filter_commands.cpp +++ b/src/mongo/db/commands/index_filter_commands.cpp @@ -94,13 +94,11 @@ static Status getQuerySettingsAndPlanCache(OperationContext* opCtx, // available to the client. // -MONGO_INITIALIZER_WITH_PREREQUISITES(SetupIndexFilterCommands, MONGO_NO_PREREQUISITES) +MONGO_INITIALIZER_WITH_PREREQUISITES(SetupIndexFilterCommands, ()) (InitializerContext* context) { new ListFilters(); new ClearFilters(); new SetFilter(); - - return Status::OK(); } } // namespace diff --git a/src/mongo/db/commands/isself.cpp b/src/mongo/db/commands/isself.cpp index 0a118ffa566..c2b5e716523 100644 --- a/src/mongo/db/commands/isself.cpp +++ b/src/mongo/db/commands/isself.cpp @@ -69,7 +69,6 @@ MONGO_INITIALIZER_WITH_PREREQUISITES(RegisterIsSelfCommand, ("GenerateInstanceId (InitializerContext* context) { // Leaked intentionally: a Command registers itself when constructed new IsSelfCommand(); - return Status::OK(); } } // namespace mongo diff --git a/src/mongo/db/commands/oplog_note.cpp b/src/mongo/db/commands/oplog_note.cpp index 74aeecbbc64..2188631a109 100644 --- a/src/mongo/db/commands/oplog_note.cpp +++ b/src/mongo/db/commands/oplog_note.cpp @@ -154,7 +154,6 @@ public: MONGO_INITIALIZER(RegisterAppendOpLogNoteCmd)(InitializerContext* context) { new AppendOplogNoteCmd(); - return Status::OK(); } } // namespace mongo diff --git a/src/mongo/db/commands/test_commands.cpp b/src/mongo/db/commands/test_commands.cpp index 382b8978400..58d75f67e71 100644 --- a/src/mongo/db/commands/test_commands.cpp +++ b/src/mongo/db/commands/test_commands.cpp @@ -34,7 +34,6 @@ #include "mongo/platform/basic.h" #include "mongo/base/init.h" -#include "mongo/base/initializer_context.h" #include "mongo/db/catalog/capped_utils.h" #include "mongo/db/catalog/collection.h" #include "mongo/db/client.h" diff --git a/src/mongo/db/commands/top_command.cpp b/src/mongo/db/commands/top_command.cpp index 328b318a73f..50999b993c1 100644 --- a/src/mongo/db/commands/top_command.cpp +++ b/src/mongo/db/commands/top_command.cpp @@ -88,7 +88,5 @@ public: MONGO_INITIALIZER(RegisterTopCommand)(InitializerContext* context) { new TopCommand(); - - return Status::OK(); } } // namespace diff --git a/src/mongo/db/exec/sbe/stages/exchange.cpp b/src/mongo/db/exec/sbe/stages/exchange.cpp index af748cb4089..a2e932d3553 100644 --- a/src/mongo/db/exec/sbe/stages/exchange.cpp +++ b/src/mongo/db/exec/sbe/stages/exchange.cpp @@ -45,8 +45,6 @@ MONGO_INITIALIZER(s_globalThreadPool)(InitializerContext* context) { options.onCreateThread = [](const std::string& name) { Client::initThread(name); }; s_globalThreadPool = std::make_unique<ThreadPool>(options); s_globalThreadPool->startup(); - - return Status::OK(); } ExchangePipe::ExchangePipe(size_t size) { diff --git a/src/mongo/db/free_mon/free_mon_controller_test.cpp b/src/mongo/db/free_mon/free_mon_controller_test.cpp index 4225e71efbb..e074e73c7f0 100644 --- a/src/mongo/db/free_mon/free_mon_controller_test.cpp +++ b/src/mongo/db/free_mon/free_mon_controller_test.cpp @@ -41,7 +41,6 @@ #include "mongo/db/free_mon/free_mon_storage.h" #include "mongo/base/data_type_validated.h" -#include "mongo/base/deinitializer_context.h" #include "mongo/bson/bson_validate.h" #include "mongo/bson/bsonmisc.h" #include "mongo/bson/bsonobjbuilder.h" diff --git a/src/mongo/db/free_mon/free_mon_options.cpp b/src/mongo/db/free_mon/free_mon_options.cpp index 173d11847e2..df1255e1200 100644 --- a/src/mongo/db/free_mon/free_mon_options.cpp +++ b/src/mongo/db/free_mon/free_mon_options.cpp @@ -35,7 +35,6 @@ #include "mongo/db/free_mon/free_mon_options.h" #include "mongo/base/error_codes.h" -#include "mongo/base/initializer_context.h" #include "mongo/base/status.h" #include "mongo/base/status_with.h" #include "mongo/base/string_data.h" @@ -92,8 +91,8 @@ Status storeFreeMonitoringOptions(const moe::Environment& params) { return Status::OK(); } -MONGO_STARTUP_OPTIONS_STORE(FreeMonitoringOptions)(InitializerContext* /*unused*/) { - return storeFreeMonitoringOptions(moe::startupOptionsParsed); +MONGO_STARTUP_OPTIONS_STORE(FreeMonitoringOptions)(InitializerContext*) { + uassertStatusOK(storeFreeMonitoringOptions(moe::startupOptionsParsed)); } } // namespace diff --git a/src/mongo/db/ftdc/ftdc_commands.cpp b/src/mongo/db/ftdc/ftdc_commands.cpp index bd403010ebc..aa274c1858e 100644 --- a/src/mongo/db/ftdc/ftdc_commands.cpp +++ b/src/mongo/db/ftdc/ftdc_commands.cpp @@ -106,8 +106,6 @@ Command* ftdcCommand; MONGO_INITIALIZER(CreateDiagnosticDataCommand)(InitializerContext* context) { ftdcCommand = new GetDiagnosticDataCommand(); - - return Status::OK(); } } // namespace diff --git a/src/mongo/db/fts/fts_index_format.cpp b/src/mongo/db/fts/fts_index_format.cpp index a6f12f6cef5..418ea2d8629 100644 --- a/src/mongo/db/fts/fts_index_format.cpp +++ b/src/mongo/db/fts/fts_index_format.cpp @@ -107,7 +107,6 @@ MONGO_INITIALIZER(FTSIndexFormat)(InitializerContext* context) { b.appendNull(""); nullObj = b.obj(); nullElt = nullObj.firstElement(); - return Status::OK(); } void FTSIndexFormat::getKeys(SharedBufferFragmentBuilder& pooledBufferBuilder, diff --git a/src/mongo/db/fts/stop_words.cpp b/src/mongo/db/fts/stop_words.cpp index 39be67707bc..9c415a2d262 100644 --- a/src/mongo/db/fts/stop_words.cpp +++ b/src/mongo/db/fts/stop_words.cpp @@ -68,7 +68,6 @@ MONGO_INITIALIZER(StopWords)(InitializerContext* context) { for (StringMap<std::set<std::string>>::const_iterator i = raw.begin(); i != raw.end(); ++i) { StopWordsMap[i->first].reset(new StopWords(i->second)); } - return Status::OK(); } } // namespace fts } // namespace mongo diff --git a/src/mongo/db/geo/r2_region_coverer_test.cpp b/src/mongo/db/geo/r2_region_coverer_test.cpp index 806fc9d4e37..0a499f2a74a 100644 --- a/src/mongo/db/geo/r2_region_coverer_test.cpp +++ b/src/mongo/db/geo/r2_region_coverer_test.cpp @@ -59,7 +59,6 @@ MONGO_INITIALIZER(R2CellUnion_Test)(InitializerContext* context) { } generator.seed(seed); LOGV2(20640, "R2CellUnion Test - Random Number Generator Seed: {seed}", "seed"_attr = seed); - return Status::OK(); } // Returns an integral number in [lower, upper] diff --git a/src/mongo/db/initialize_server_global_state.cpp b/src/mongo/db/initialize_server_global_state.cpp index aef5a665d4f..6dd9a7ef69d 100644 --- a/src/mongo/db/initialize_server_global_state.cpp +++ b/src/mongo/db/initialize_server_global_state.cpp @@ -298,8 +298,8 @@ MONGO_INITIALIZER_GENERAL(ServerLogRedirection, if (serverGlobalParams.logWithSyslog) { #ifdef _WIN32 - return Status(ErrorCodes::InternalError, - "Syslog requested in Windows build; command line processor logic error"); + uasserted(ErrorCodes::InternalError, + "Syslog requested in Windows build; command line processor logic error"); #else lv2Config.consoleEnabled = false; lv2Config.syslogEnabled = true; @@ -316,16 +316,16 @@ MONGO_INITIALIZER_GENERAL(ServerLogRedirection, try { exists = boost::filesystem::exists(absoluteLogpath); } catch (boost::filesystem::filesystem_error& e) { - return Status(ErrorCodes::FileNotOpen, - str::stream() << "Failed probe for \"" << absoluteLogpath - << "\": " << e.code().message()); + uasserted(ErrorCodes::FileNotOpen, + str::stream() << "Failed probe for \"" << absoluteLogpath + << "\": " << e.code().message()); } if (exists) { if (boost::filesystem::is_directory(absoluteLogpath)) { - return Status(ErrorCodes::FileNotOpen, - str::stream() << "logpath \"" << absoluteLogpath - << "\" should name a file, not a directory."); + uasserted(ErrorCodes::FileNotOpen, + str::stream() << "logpath \"" << absoluteLogpath + << "\" should name a file, not a directory."); } if (!serverGlobalParams.logAppend && boost::filesystem::is_regular(absoluteLogpath)) { @@ -339,12 +339,11 @@ MONGO_INITIALIZER_GENERAL(ServerLogRedirection, "oldLogPath"_attr = absoluteLogpath, "newLogPath"_attr = renameTarget); } else { - return Status(ErrorCodes::FileRenameFailed, - str::stream() - << "Could not rename preexisting log file \"" - << absoluteLogpath << "\" to \"" << renameTarget - << "\"; run with --logappend or manually remove file: " - << ec.message()); + uasserted(ErrorCodes::FileRenameFailed, + str::stream() << "Could not rename preexisting log file \"" + << absoluteLogpath << "\" to \"" << renameTarget + << "\"; run with --logappend or manually remove file: " + << ec.message()); } } } @@ -369,8 +368,7 @@ MONGO_INITIALIZER_GENERAL(ServerLogRedirection, if (result.isOK() && writeServerRestartedAfterLogConfig) { LOGV2(20698, "***** SERVER RESTARTED *****"); } - - return result; + uassertStatusOK(result); } /** @@ -389,8 +387,7 @@ static void shortCircuitExit() { MONGO_INITIALIZER(RegisterShortCircuitExitHandler)(InitializerContext*) { if (std::atexit(&shortCircuitExit) != 0) - return Status(ErrorCodes::InternalError, "Failed setting short-circuit exit handler."); - return Status::OK(); + uasserted(ErrorCodes::InternalError, "Failed setting short-circuit exit handler."); } bool initializeServerGlobalState(ServiceContext* service, PidFileWrite pidWrite) { @@ -447,8 +444,6 @@ MONGO_INITIALIZER_GENERAL(MungeUmask, ("EndStartupOptionHandling"), ("ServerLogR // in order to pull out the user portion of the current umask. umask((umask(S_IRWXU | S_IRWXG | S_IRWXO) & S_IRWXU) | getUmaskOverride()); } - - return Status::OK(); } } // namespace #endif diff --git a/src/mongo/db/logical_time_validator.cpp b/src/mongo/db/logical_time_validator.cpp index d88bbbd3294..c56a3a146f0 100644 --- a/src/mongo/db/logical_time_validator.cpp +++ b/src/mongo/db/logical_time_validator.cpp @@ -64,7 +64,6 @@ MONGO_INITIALIZER(InitializeAdvanceClusterTimePrivilegeVector)(InitializerContex ActionSet actions; actions.addAction(ActionType::advanceClusterTime); advanceClusterTimePrivilege.emplace_back(ResourcePattern::forClusterResource(), actions); - return Status::OK(); } Milliseconds kRefreshIntervalIfErrored(200); diff --git a/src/mongo/db/matcher/expression_parser.cpp b/src/mongo/db/matcher/expression_parser.cpp index e8d2acfd489..197cc481e3c 100644 --- a/src/mongo/db/matcher/expression_parser.cpp +++ b/src/mongo/db/matcher/expression_parser.cpp @@ -1981,7 +1981,6 @@ MONGO_INITIALIZER(PathlessOperatorMap)(InitializerContext* context) { {"text", &parseText}, {"where", &parseWhere}, }); - return Status::OK(); } // Maps from query operator string name to operator PathAcceptingKeyword. @@ -2036,7 +2035,6 @@ MONGO_INITIALIZER(MatchExpressionParser)(InitializerContext* context) { {"type", PathAcceptingKeyword::TYPE}, {"within", PathAcceptingKeyword::WITHIN}, }); - return Status::OK(); } /** diff --git a/src/mongo/db/mongod_main.cpp b/src/mongo/db/mongod_main.cpp index b355becdf2a..2a3489eb2be 100644 --- a/src/mongo/db/mongod_main.cpp +++ b/src/mongo/db/mongod_main.cpp @@ -290,7 +290,6 @@ MONGO_INITIALIZER_WITH_PREREQUISITES(WireSpec, ("EndStartupOptionHandling"))(Ini spec.isInternalClient = true; WireSpec::instance().initialize(std::move(spec)); - return Status::OK(); } void initializeCommandHooks(ServiceContext* serviceContext) { @@ -812,7 +811,6 @@ ExitCode initService() { MONGO_INITIALIZER_GENERAL(ForkServer, ("EndStartupOptionHandling"), ("default")) (InitializerContext* context) { mongo::forkServerOrDie(); - return Status::OK(); } /* @@ -1022,10 +1020,9 @@ void setUpObservers(ServiceContext* serviceContext) { } #ifdef MONGO_CONFIG_SSL -MONGO_INITIALIZER_GENERAL(setSSLManagerType, MONGO_NO_PREREQUISITES, ("SSLManager")) +MONGO_INITIALIZER_GENERAL(setSSLManagerType, (), ("SSLManager")) (InitializerContext* context) { isSSLServer = true; - return Status::OK(); } #endif diff --git a/src/mongo/db/mongod_options.cpp b/src/mongo/db/mongod_options.cpp index fbc888172cf..db09e05615f 100644 --- a/src/mongo/db/mongod_options.cpp +++ b/src/mongo/db/mongod_options.cpp @@ -695,7 +695,6 @@ MONGO_INITIALIZER(IgnoreEnableMajorityReadConcernWarning) "Ignoring read concern override as config server requires majority read " "concern"); } - return Status::OK(); } } // namespace mongo diff --git a/src/mongo/db/mongod_options_init.cpp b/src/mongo/db/mongod_options_init.cpp index 8d9a28d7dfe..34d0ac03e2d 100644 --- a/src/mongo/db/mongod_options_init.cpp +++ b/src/mongo/db/mongod_options_init.cpp @@ -38,7 +38,7 @@ namespace mongo { MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(MongodOptions)(InitializerContext* context) { - return addMongodOptions(&moe::startupOptions); + uassertStatusOK(addMongodOptions(&moe::startupOptions)); } MONGO_INITIALIZER_GENERAL(MongodOptions, @@ -50,23 +50,10 @@ MONGO_INITIALIZER_GENERAL(MongodOptions, } // Run validation, but tell the Environment that we don't want it to be set as "valid", // since we may be making it invalid in the canonicalization process. - Status ret = moe::startupOptionsParsed.validate(false /*setValid*/); - if (!ret.isOK()) { - return ret; - } - ret = validateMongodOptions(moe::startupOptionsParsed); - if (!ret.isOK()) { - return ret; - } - ret = canonicalizeMongodOptions(&moe::startupOptionsParsed); - if (!ret.isOK()) { - return ret; - } - ret = moe::startupOptionsParsed.validate(); - if (!ret.isOK()) { - return ret; - } - return Status::OK(); + uassertStatusOK(moe::startupOptionsParsed.validate(false /*setValid*/)); + uassertStatusOK(validateMongodOptions(moe::startupOptionsParsed)); + uassertStatusOK(canonicalizeMongodOptions(&moe::startupOptionsParsed)); + uassertStatusOK(moe::startupOptionsParsed.validate()); } MONGO_INITIALIZER_GENERAL(CoreOptions_Store, @@ -79,7 +66,6 @@ MONGO_INITIALIZER_GENERAL(CoreOptions_Store, std::cerr << "try '" << context->args()[0] << " --help' for more information" << std::endl; quickExit(EXIT_BADOPTIONS); } - return Status::OK(); } } // namespace mongo diff --git a/src/mongo/db/pipeline/accumulation_statement.h b/src/mongo/db/pipeline/accumulation_statement.h index 83f0ad5561c..3d1b3a69b98 100644 --- a/src/mongo/db/pipeline/accumulation_statement.h +++ b/src/mongo/db/pipeline/accumulation_statement.h @@ -46,13 +46,11 @@ namespace mongo { #define REGISTER_ACCUMULATOR(key, factory) \ MONGO_INITIALIZER(addToAccumulatorFactoryMap_##key)(InitializerContext*) { \ AccumulationStatement::registerAccumulator("$" #key, (factory), boost::none); \ - return Status::OK(); \ } #define REGISTER_ACCUMULATOR_WITH_MIN_VERSION(key, factory, minVersion) \ MONGO_INITIALIZER(addToAccumulatorFactoryMap_##key)(InitializerContext*) { \ AccumulationStatement::registerAccumulator("$" #key, (factory), (minVersion)); \ - return Status::OK(); \ } /** diff --git a/src/mongo/db/pipeline/document_source.h b/src/mongo/db/pipeline/document_source.h index a1c65ea48d0..8aa736d4b9f 100644 --- a/src/mongo/db/pipeline/document_source.h +++ b/src/mongo/db/pipeline/document_source.h @@ -90,7 +90,7 @@ class Document; #define REGISTER_DOCUMENT_SOURCE_CONDITIONALLY(key, liteParser, fullParser, minVersion, ...) \ MONGO_INITIALIZER(addToDocSourceParserMap_##key)(InitializerContext*) { \ if (!__VA_ARGS__) { \ - return Status::OK(); \ + return; \ } \ auto fullParserWrapper = [](BSONElement stageSpec, \ const boost::intrusive_ptr<ExpressionContext>& expCtx) { \ @@ -99,7 +99,6 @@ class Document; }; \ LiteParsedDocumentSource::registerParser("$" #key, liteParser); \ DocumentSource::registerParser("$" #key, fullParserWrapper, minVersion); \ - return Status::OK(); \ } #define REGISTER_DOCUMENT_SOURCE(key, liteParser, fullParser) \ @@ -129,7 +128,6 @@ class Document; MONGO_INITIALIZER(addAliasToDocSourceParserMap_##key)(InitializerContext*) { \ LiteParsedDocumentSource::registerParser("$" #key, (liteParser)); \ DocumentSource::registerParser("$" #key, (fullParser), boost::none); \ - return Status::OK(); \ } class DocumentSource : public RefCountable { diff --git a/src/mongo/db/pipeline/expression.cpp b/src/mongo/db/pipeline/expression.cpp index 06481c5d953..9fcfad4daff 100644 --- a/src/mongo/db/pipeline/expression.cpp +++ b/src/mongo/db/pipeline/expression.cpp @@ -6715,7 +6715,6 @@ void ExpressionToHashedIndexKey::_doAddDependencies(DepsTracker* deps) const { MONGO_INITIALIZER(expressionParserMap)(InitializerContext*) { // Nothing to do. This initializer exists to tie together all the individual initializers // defined by REGISTER_EXPRESSION / REGISTER_EXPRESSION_WITH_MIN_VERSION. - return Status::OK(); } } // namespace mongo diff --git a/src/mongo/db/pipeline/expression.h b/src/mongo/db/pipeline/expression.h index 647f7a24527..ef95686c879 100644 --- a/src/mongo/db/pipeline/expression.h +++ b/src/mongo/db/pipeline/expression.h @@ -73,7 +73,6 @@ class DocumentSource; MONGO_INITIALIZER_GENERAL(addToExpressionParserMap_##key, (), ("expressionParserMap")) \ (InitializerContext*) { \ Expression::registerExpression("$" #key, (parser), boost::none); \ - return Status::OK(); \ } /** @@ -89,7 +88,6 @@ class DocumentSource; MONGO_INITIALIZER_GENERAL(addToExpressionParserMap_##key, (), ("expressionParserMap")) \ (InitializerContext*) { \ Expression::registerExpression("$" #key, (parser), (minVersion)); \ - return Status::OK(); \ } /** @@ -103,7 +101,6 @@ class DocumentSource; if (getTestCommandsEnabled()) { \ Expression::registerExpression("$" #key, (parser), boost::none); \ } \ - return Status::OK(); \ } class Expression : public RefCountable { diff --git a/src/mongo/db/pipeline/granularity_rounder.h b/src/mongo/db/pipeline/granularity_rounder.h index 813e11b971e..a3cdb0c6086 100644 --- a/src/mongo/db/pipeline/granularity_rounder.h +++ b/src/mongo/db/pipeline/granularity_rounder.h @@ -55,7 +55,6 @@ namespace mongo { #define REGISTER_GRANULARITY_ROUNDER_GENERAL(name, key, rounder) \ MONGO_INITIALIZER(addToGranularityRounderMap_##key)(InitializerContext*) { \ GranularityRounder::registerGranularityRounder(name, rounder); \ - return Status::OK(); \ } /** diff --git a/src/mongo/db/profile_filter_impl.cpp b/src/mongo/db/profile_filter_impl.cpp index 7f76083bd22..b010b51841b 100644 --- a/src/mongo/db/profile_filter_impl.cpp +++ b/src/mongo/db/profile_filter_impl.cpp @@ -83,7 +83,6 @@ MONGO_INITIALIZER_GENERAL(ProfileFilterDefault, if (auto expr = serverGlobalParams.defaultProfileFilter) { ProfileFilter::setDefault(std::make_shared<ProfileFilterImpl>(*expr)); } - return Status::OK(); } catch (AssertionException& e) { // Add more context to the error uasserted(ErrorCodes::FailedToParse, diff --git a/src/mongo/db/query/collation/collator_factory_icu_decoration.cpp b/src/mongo/db/query/collation/collator_factory_icu_decoration.cpp index 6eacae4c5a1..6ca6ae52ee6 100644 --- a/src/mongo/db/query/collation/collator_factory_icu_decoration.cpp +++ b/src/mongo/db/query/collation/collator_factory_icu_decoration.cpp @@ -36,13 +36,10 @@ #include "mongo/db/service_context.h" namespace mongo { - namespace { - ServiceContext::ConstructorActionRegisterer registerIcuCollator{ "CreateCollatorFactory", {"LoadICUData"}, [](ServiceContext* service) { CollatorFactoryInterface::set(service, std::make_unique<CollatorFactoryICU>()); }}; } // namespace - } // namespace mongo diff --git a/src/mongo/db/repl/data_replicator_external_state_impl.cpp b/src/mongo/db/repl/data_replicator_external_state_impl.cpp index 31bb90785cd..8e693456799 100644 --- a/src/mongo/db/repl/data_replicator_external_state_impl.cpp +++ b/src/mongo/db/repl/data_replicator_external_state_impl.cpp @@ -55,10 +55,9 @@ const char kBlockingQueueOplogBufferName[] = "inMemoryBlockingQueue"; MONGO_INITIALIZER(initialSyncOplogBuffer)(InitializerContext*) { if ((initialSyncOplogBuffer != kCollectionOplogBufferName) && (initialSyncOplogBuffer != kBlockingQueueOplogBufferName)) { - return Status(ErrorCodes::BadValue, - "unsupported initial sync oplog buffer option: " + initialSyncOplogBuffer); + uasserted(ErrorCodes::BadValue, + "unsupported initial sync oplog buffer option: " + initialSyncOplogBuffer); } - return Status::OK(); } } // namespace diff --git a/src/mongo/db/repl/isself.cpp b/src/mongo/db/repl/isself.cpp index 1c561ff9f5d..85549d118d3 100644 --- a/src/mongo/db/repl/isself.cpp +++ b/src/mongo/db/repl/isself.cpp @@ -84,7 +84,6 @@ OID instanceId; MONGO_INITIALIZER(GenerateInstanceId)(InitializerContext*) { instanceId = OID::gen(); - return Status::OK(); } namespace { diff --git a/src/mongo/db/s/balancer/core_options_stub.cpp b/src/mongo/db/s/balancer/core_options_stub.cpp index 2b9c5d8b837..234d91c322a 100644 --- a/src/mongo/db/s/balancer/core_options_stub.cpp +++ b/src/mongo/db/s/balancer/core_options_stub.cpp @@ -35,8 +35,6 @@ namespace { MONGO_INITIALIZER_GENERAL(CoreOptions_Store, ("BeginStartupOptionStorage"), ("EndStartupOptionStorage")) -(InitializerContext* context) { - return Status::OK(); -} +(InitializerContext* context) {} } // namespace } // namespace mongo diff --git a/src/mongo/db/s/config/configsvr_control_balancer_command.cpp b/src/mongo/db/s/config/configsvr_control_balancer_command.cpp index 407828446fa..10fa0aa6739 100644 --- a/src/mongo/db/s/config/configsvr_control_balancer_command.cpp +++ b/src/mongo/db/s/config/configsvr_control_balancer_command.cpp @@ -148,8 +148,6 @@ MONGO_INITIALIZER(ClusterBalancerControlCommands)(InitializerContext* context) { new ConfigSvrBalancerStartCommand(); new ConfigSvrBalancerStopCommand(); new ConfigSvrBalancerStatusCommand(); - - return Status::OK(); } } // namespace diff --git a/src/mongo/db/server_options_init.cpp b/src/mongo/db/server_options_init.cpp index 29a278981ff..6396125dc77 100644 --- a/src/mongo/db/server_options_init.cpp +++ b/src/mongo/db/server_options_init.cpp @@ -36,7 +36,7 @@ MONGO_INITIALIZER_GENERAL(ServerOptions_Setup, ("BeginStartupOptionSetup"), ("EndStartupOptionSetup")) (InitializerContext* context) { - return setupServerOptions(context->args()); + uassertStatusOK(setupServerOptions(context->args())); } } // namespace mongo diff --git a/src/mongo/db/server_options_test.cpp b/src/mongo/db/server_options_test.cpp index d09cde9b797..5cc26ccd3c1 100644 --- a/src/mongo/db/server_options_test.cpp +++ b/src/mongo/db/server_options_test.cpp @@ -75,7 +75,6 @@ namespace moe = mongo::optionenvironment; MONGO_INITIALIZER(ServerLogRedirection)(mongo::InitializerContext*) { // ssl_options_server.cpp has an initializer which depends on logging. // We can stub that dependency out for unit testing purposes. - return Status::OK(); } class OptionsParserTester : public moe::OptionsParser { diff --git a/src/mongo/db/service_context.cpp b/src/mongo/db/service_context.cpp index d69416b33b0..7fa4b4f637c 100644 --- a/src/mongo/db/service_context.cpp +++ b/src/mongo/db/service_context.cpp @@ -467,20 +467,16 @@ ServiceContext::ConstructorActionRegisterer::ConstructorActionRegisterer( DestructorAction destructor) { if (!destructor) destructor = [](ServiceContext*) {}; - _registerer.emplace(std::move(name), - [this, constructor, destructor](InitializerContext* context) { - _iter = registeredConstructorActions().emplace( - registeredConstructorActions().end(), - std::move(constructor), - std::move(destructor)); - return Status::OK(); - }, - [this](DeinitializerContext* context) { - registeredConstructorActions().erase(_iter); - return Status::OK(); - }, - std::move(prereqs), - std::move(dependents)); + _registerer.emplace( + std::move(name), + [this, constructor, destructor](InitializerContext*) { + _iter = registeredConstructorActions().emplace(registeredConstructorActions().end(), + std::move(constructor), + std::move(destructor)); + }, + [this](DeinitializerContext*) { registeredConstructorActions().erase(_iter); }, + std::move(prereqs), + std::move(dependents)); } ServiceContext::UniqueServiceContext ServiceContext::make() { diff --git a/src/mongo/db/service_context.h b/src/mongo/db/service_context.h index 4b900fa6384..1e4dffda45e 100644 --- a/src/mongo/db/service_context.h +++ b/src/mongo/db/service_context.h @@ -35,7 +35,6 @@ #include <memory> #include <vector> -#include "mongo/base/global_initializer_registerer.h" #include "mongo/db/logical_session_id.h" #include "mongo/db/storage/storage_engine.h" #include "mongo/platform/atomic_word.h" diff --git a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_kv_engine_test.cpp b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_kv_engine_test.cpp index e249daed751..76c5c843ff9 100644 --- a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_kv_engine_test.cpp +++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_kv_engine_test.cpp @@ -73,7 +73,6 @@ std::unique_ptr<mongo::KVHarnessHelper> makeHelper() { MONGO_INITIALIZER(RegisterEphemeralForTestKVHarnessFactory)(InitializerContext*) { KVHarnessHelper::registerFactory(makeHelper); - return Status::OK(); } class EphemeralForTestKVEngineTest : public unittest::Test { diff --git a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store_test.cpp b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store_test.cpp index ec4c5db41ed..278510f7c16 100644 --- a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store_test.cpp +++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store_test.cpp @@ -91,9 +91,8 @@ std::unique_ptr<mongo::RecordStoreHarnessHelper> makeRecordStoreHarnessHelper() return std::make_unique<RecordStoreHarnessHelper>(); } -MONGO_INITIALIZER(RegisterRecordStoreHarnessFactory)(InitializerContext* const) { +MONGO_INITIALIZER(RegisterRecordStoreHarnessFactory)(InitializerContext*) { mongo::registerRecordStoreHarnessHelperFactory(makeRecordStoreHarnessHelper); - return Status::OK(); } } // namespace } // namespace ephemeral_for_test diff --git a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_recovery_unit_test.cpp b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_recovery_unit_test.cpp index d796c783c4e..fbcf2b5fb9d 100644 --- a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_recovery_unit_test.cpp +++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_recovery_unit_test.cpp @@ -69,7 +69,6 @@ std::unique_ptr<mongo::RecoveryUnitHarnessHelper> makeRecoveryUnitHarnessHelper( MONGO_INITIALIZER(RegisterRecoveryUnitHarnessFactory)(InitializerContext* const) { mongo::registerRecoveryUnitHarnessHelperFactory(makeRecoveryUnitHarnessHelper); - return Status::OK(); } } // namespace diff --git a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_sorted_impl_test.cpp b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_sorted_impl_test.cpp index 7b3c88a4532..be04273b3f2 100644 --- a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_sorted_impl_test.cpp +++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_sorted_impl_test.cpp @@ -104,7 +104,6 @@ std::unique_ptr<mongo::SortedDataInterfaceHarnessHelper> makeSortedDataInterface MONGO_INITIALIZER(RegisterSortedDataInterfaceHarnessFactory)(InitializerContext* const) { mongo::registerSortedDataInterfaceHarnessHelperFactory(makeSortedDataInterfaceHarnessHelper); - return Status::OK(); } } // namespace } // namespace ephemeral_for_test diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp index 8bf3312e1c2..e5d2fda83c0 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp @@ -397,7 +397,6 @@ std::unique_ptr<KVHarnessHelper> makeHelper() { MONGO_INITIALIZER(RegisterKVHarnessFactory)(InitializerContext*) { KVHarnessHelper::registerFactory(makeHelper); - return Status::OK(); } } // namespace diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_options_init.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_options_init.cpp index 90292778505..9773f267e05 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_options_init.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_options_init.cpp @@ -48,6 +48,5 @@ MONGO_STARTUP_OPTIONS_STORE(WiredTigerOptions)(InitializerContext* context) { std::cerr << "try '" << context->args()[0] << " --help' for more information" << std::endl; ::_exit(EXIT_BADOPTIONS); } - return Status::OK(); } } // namespace mongo diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_prefixed_index_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_prefixed_index_test.cpp index 20afb98beac..e29e7ca4b17 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_prefixed_index_test.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_prefixed_index_test.cpp @@ -147,7 +147,6 @@ std::unique_ptr<SortedDataInterfaceHarnessHelper> makeWTPrefixedIndexHarnessHelp MONGO_INITIALIZER(RegisterSortedDataInterfaceHarnessFactory)(InitializerContext* const) { mongo::registerSortedDataInterfaceHarnessHelperFactory(makeWTPrefixedIndexHarnessHelper); - return Status::OK(); } } // namespace } // namespace mongo diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_prefixed_record_store_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_prefixed_record_store_test.cpp index aabe631120d..43c6e9a706e 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_prefixed_record_store_test.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_prefixed_record_store_test.cpp @@ -203,7 +203,6 @@ std::unique_ptr<RecordStoreHarnessHelper> makeWTRSHarnessHelper() { MONGO_INITIALIZER(RegisterRecordStoreHarnessFactory)(InitializerContext* const) { mongo::registerRecordStoreHarnessHelperFactory(makeWTRSHarnessHelper); - return Status::OK(); } TEST(WiredTigerRecordStoreTest, PrefixedTableScan) { diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp index c7ba49f4c61..0fe252a0f3a 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp @@ -127,7 +127,6 @@ std::unique_ptr<RecoveryUnitHarnessHelper> makeWTRUHarnessHelper() { MONGO_INITIALIZER(RegisterHarnessFactory)(InitializerContext* const) { mongo::registerRecoveryUnitHarnessHelperFactory(makeWTRUHarnessHelper); - return Status::OK(); } class WiredTigerRecoveryUnitTestFixture : public unittest::Test { diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp index 05a9eb69c23..4113027a395 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp @@ -148,7 +148,6 @@ std::unique_ptr<SortedDataInterfaceHarnessHelper> makeWTIndexHarnessHelper() { MONGO_INITIALIZER(RegisterSortedDataInterfaceHarnessFactory)(InitializerContext* const) { mongo::registerSortedDataInterfaceHarnessHelperFactory(makeWTIndexHarnessHelper); - return Status::OK(); } TEST(WiredTigerStandardIndexText, CursorInActiveTxnAfterNext) { diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_standard_record_store_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_standard_record_store_test.cpp index 78b627ed40c..1f93a9fc63c 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_standard_record_store_test.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_standard_record_store_test.cpp @@ -200,7 +200,6 @@ std::unique_ptr<RecordStoreHarnessHelper> makeWTRSHarnessHelper() { MONGO_INITIALIZER(RegisterRecordStoreHarnessFactory)(InitializerContext* const) { mongo::registerRecordStoreHarnessHelperFactory(makeWTRSHarnessHelper); - return Status::OK(); } TEST(WiredTigerRecordStoreTest, StorageSizeStatisticsDisabled) { diff --git a/src/mongo/db/system_index.cpp b/src/mongo/db/system_index.cpp index b08598d0f51..c2eedda74ea 100644 --- a/src/mongo/db/system_index.cpp +++ b/src/mongo/db/system_index.cpp @@ -85,8 +85,6 @@ MONGO_INITIALIZER(AuthIndexKeyPatterns)(InitializerContext*) { v3SystemRolesIndexSpec.addKeys(v3SystemRolesKeyPattern); v3SystemRolesIndexSpec.unique(); v3SystemRolesIndexSpec.name(v3SystemRolesIndexName); - - return Status::OK(); } void generateSystemIndexForExistingCollection(OperationContext* opCtx, diff --git a/src/mongo/db/traffic_recorder.cpp b/src/mongo/db/traffic_recorder.cpp index f13388e1892..7cbfaeef7c5 100644 --- a/src/mongo/db/traffic_recorder.cpp +++ b/src/mongo/db/traffic_recorder.cpp @@ -54,22 +54,20 @@ bool shouldAlwaysRecordTraffic = false; MONGO_INITIALIZER(ShouldAlwaysRecordTraffic)(InitializerContext*) { if (!gAlwaysRecordTraffic.size()) { - return Status::OK(); + return; } if (gTrafficRecordingDirectory.empty()) { if (serverGlobalParams.logpath.empty()) { - return Status(ErrorCodes::BadValue, - "invalid to set AlwaysRecordTraffic without a logpath or " - "trafficRecordingDirectory"); + uasserted(ErrorCodes::BadValue, + "invalid to set AlwaysRecordTraffic without a logpath or " + "trafficRecordingDirectory"); } else { gTrafficRecordingDirectory = serverGlobalParams.logpath; } } shouldAlwaysRecordTraffic = true; - - return Status::OK(); } } // namespace diff --git a/src/mongo/db/update/modifier_table.cpp b/src/mongo/db/update/modifier_table.cpp index ed054989547..9e181b40dc1 100644 --- a/src/mongo/db/update/modifier_table.cpp +++ b/src/mongo/db/update/modifier_table.cpp @@ -123,8 +123,6 @@ MONGO_INITIALIZER(ModifierTable)(InitializerContext* context) { MODIFIER_NAME_MAP = new NameMap( SimpleStringDataComparator::kInstance.makeStringDataUnorderedMap<ModifierEntry*>()); init(MODIFIER_NAME_MAP); - - return Status::OK(); } ModifierType getType(StringData typeStr) { |