diff options
author | Jack Mulrow <jack.mulrow@mongodb.com> | 2020-01-08 15:35:46 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2020-01-08 15:35:46 +0000 |
commit | e3dd9e80e38f3528bc50c3e1115c46a0687885fa (patch) | |
tree | f8a9a724ed170e45ecf1f0cc73c086ad82c45c0e /src/mongo/db/read_write_concern_defaults.cpp | |
parent | d401d80a2c89d89db26750956cb3b3261e595a34 (diff) | |
download | mongo-e3dd9e80e38f3528bc50c3e1115c46a0687885fa.tar.gz |
SERVER-45282 Unify how mongos and mongod default RWC caches handle deleted defaults document
Diffstat (limited to 'src/mongo/db/read_write_concern_defaults.cpp')
-rw-r--r-- | src/mongo/db/read_write_concern_defaults.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/mongo/db/read_write_concern_defaults.cpp b/src/mongo/db/read_write_concern_defaults.cpp index 4b77b993b1b..d43a2d2258d 100644 --- a/src/mongo/db/read_write_concern_defaults.cpp +++ b/src/mongo/db/read_write_concern_defaults.cpp @@ -54,7 +54,7 @@ public: const boost::optional<BSONObj>& newDefaultsDoc) : _service(service), _rwcDefaults(rwcDefaults) { // Note this will throw if the document can't be parsed. In the case of a delete, there will - // be no new defaults document and the RWConcern will be default constructed, which matches + // be no new defaults document and the RWConcern will be default constructed, which matches // the behavior when lookup discovers a non-existent defaults document. _rwc = newDefaultsDoc ? RWConcernDefault::parse(IDLParserErrorContext("RWDefaultsWriteObserver"), @@ -173,9 +173,10 @@ void ReadWriteConcernDefaults::refreshIfNecessary(OperationContext* opCtx) { return; } auto currentDefaultsHandle = _defaults.acquire(opCtx, Type::kReadWriteConcernEntry); - if (!currentDefaultsHandle || + if (!currentDefaultsHandle || !possibleNewDefaults->getEpoch() || (possibleNewDefaults->getEpoch() > (**currentDefaultsHandle)->getEpoch())) { - // Use the new defaults if they have a higher epoch, or if there are currently no defaults. + // Use the new defaults if they have a higher epoch, if there are no defaults in the cache, + // or if the found defaults have no epoch, meaning there are no defaults in config.settings. log() << "refreshed RWC defaults to " << possibleNewDefaults->toBSON(); setDefault(std::move(*possibleNewDefaults)); } |