-
Type: Improvement
-
Resolution: Fixed
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: Internal Code
-
Fully Compatible
-
Service Arch 2020-07-27, Service Arch 2020-08-10, Service Arch 2020-08-24, Service arch 2020-09-07, Service arch 2020-09-21, Service arch 2020-12-14
Convert initializers to throw DBException if something goes wrong, instead of returning Status. Most of the time they just return OK unconditionally, and that's easier to say with an exception protocol.
If any initializer returns a non-OK status, all initialization stops. Basically the process dies right away, and it's a gracefully fatal error to return non-OK status. Most initializers today have a single Status::OK() return statement, providing no information. It's unnecessary.
A simple change (already done) replaces all INITIALIZER return Status::OK(), or just deleting it if it's the last statement of the function. All non-OK `return expr` can be replaced with `uassertStatusOK(expr)`. There are 148 little improvements to make.
Most are simply removing a boilerplate return statement from a 1-liner like this:
MONGO_INITIALIZER_GENERAL(ForkServer, ("EndStartupOptionHandling"), ("default")) (InitializerContext* context) { mongo::forkServerOrDie(); return Status::OK(); // <== remove this }
but more substantial code is improved as well:
auto status = insertSingleName(opt._singleName); if (!status.isOK()) { return status; }
becomes
uassertStatusOK(insertSingleName(opt._singleName));
- is duplicated by
-
SERVER-40811 Eliminate MONGO_INITIALIZER kruft
- Closed
-
SERVER-43078 Make MONGO_INITIALIZER functions throw on error
- Closed
- split from
-
SERVER-40811 Eliminate MONGO_INITIALIZER kruft
- Closed