diff options
author | Adam Rayner <adam.rayner@gmail.com> | 2021-12-21 16:37:03 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-12-21 17:33:20 +0000 |
commit | 3c2effceee65bbf6bcbfcd13a4d2087d15a81aa1 (patch) | |
tree | 7b889c42f0d042344aa3ba4126215aad1a9c409f /src/mongo/db/mongod_main.cpp | |
parent | 7a8a42f465f2ac2cb05904b25fc91dff087c82cf (diff) | |
download | mongo-3c2effceee65bbf6bcbfcd13a4d2087d15a81aa1.tar.gz |
SERVER-61699 Abort startup if audit log rotate fails
Diffstat (limited to 'src/mongo/db/mongod_main.cpp')
-rw-r--r-- | src/mongo/db/mongod_main.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/mongo/db/mongod_main.cpp b/src/mongo/db/mongod_main.cpp index b5780ed1c9f..f70fec727cb 100644 --- a/src/mongo/db/mongod_main.cpp +++ b/src/mongo/db/mongod_main.cpp @@ -1512,7 +1512,18 @@ int mongod_main(int argc, char* argv[]) { } } - audit::rotateAuditLog(); + // Attempt to rotate the audit log pre-emptively on startup to avoid any potential conflicts + // with existing log state. If this rotation fails, then exit nicely with failure + try { + audit::rotateAuditLog(); + } catch (...) { + + Status err = mongo::exceptionToStatus(); + LOGV2(6169900, "Error rotating audit log", "error"_attr = err); + + quickExit(ExitCode::EXIT_AUDIT_ROTATE_ERROR); + } + setUpCollectionShardingState(service); setUpCatalog(service); setUpReplication(service); |