diff options
author | Samy Lanka <samy.lanka@mongodb.com> | 2021-05-12 04:05:56 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-05-21 01:07:54 +0000 |
commit | b5dbc41e97ae3587beb40f31490f79b9be40e4bc (patch) | |
tree | 83182a4c5b49fb4a657d9ff8811c683706c41c83 /src/mongo/db/pipeline | |
parent | 75a9401252e609dc9f91f49d985d0686cb41b0ef (diff) | |
download | mongo-b5dbc41e97ae3587beb40f31490f79b9be40e4bc.tar.gz |
SERVER-56488 Change the default read concern to always be local
(cherry picked from commit 7f901206919def001d0128a2907601a1ff2143b7)
Diffstat (limited to 'src/mongo/db/pipeline')
10 files changed, 32 insertions, 21 deletions
diff --git a/src/mongo/db/pipeline/document_source_change_stream.h b/src/mongo/db/pipeline/document_source_change_stream.h index 8768c7aee30..144dddf84d4 100644 --- a/src/mongo/db/pipeline/document_source_change_stream.h +++ b/src/mongo/db/pipeline/document_source_change_stream.h @@ -87,13 +87,14 @@ public: } } - ReadConcernSupportResult supportsReadConcern(repl::ReadConcernLevel level) const { + ReadConcernSupportResult supportsReadConcern(repl::ReadConcernLevel level, + bool isImplicitDefault) const { // Change streams require "majority" readConcern. If the client did not specify an // explicit readConcern, change streams will internally upconvert the readConcern to // majority (so clients can always send aggregations without readConcern). We therefore // do not permit the cluster-wide default to be applied. return onlySingleReadConcernSupported( - kStageName, repl::ReadConcernLevel::kMajorityReadConcern, level); + kStageName, repl::ReadConcernLevel::kMajorityReadConcern, level, isImplicitDefault); } void assertSupportsMultiDocumentTransaction() const { diff --git a/src/mongo/db/pipeline/document_source_current_op.h b/src/mongo/db/pipeline/document_source_current_op.h index ed2093c449b..49e0be6c35d 100644 --- a/src/mongo/db/pipeline/document_source_current_op.h +++ b/src/mongo/db/pipeline/document_source_current_op.h @@ -82,8 +82,9 @@ public: return true; } - ReadConcernSupportResult supportsReadConcern(repl::ReadConcernLevel level) const { - return onlyReadConcernLocalSupported(kStageName, level); + ReadConcernSupportResult supportsReadConcern(repl::ReadConcernLevel level, + bool isImplicitDefault) const { + return onlyReadConcernLocalSupported(kStageName, level, isImplicitDefault); } void assertSupportsMultiDocumentTransaction() const { diff --git a/src/mongo/db/pipeline/document_source_list_cached_and_active_users.h b/src/mongo/db/pipeline/document_source_list_cached_and_active_users.h index 35ab6dfe54c..f1f1e25e55e 100644 --- a/src/mongo/db/pipeline/document_source_list_cached_and_active_users.h +++ b/src/mongo/db/pipeline/document_source_list_cached_and_active_users.h @@ -73,8 +73,9 @@ public: return false; } - ReadConcernSupportResult supportsReadConcern(repl::ReadConcernLevel level) const { - return onlyReadConcernLocalSupported(kStageName, level); + ReadConcernSupportResult supportsReadConcern(repl::ReadConcernLevel level, + bool isImplicitDefault) const { + return onlyReadConcernLocalSupported(kStageName, level, isImplicitDefault); } void assertSupportsMultiDocumentTransaction() const { diff --git a/src/mongo/db/pipeline/document_source_list_local_sessions.h b/src/mongo/db/pipeline/document_source_list_local_sessions.h index 4615296a0ed..5306fc1fb7e 100644 --- a/src/mongo/db/pipeline/document_source_list_local_sessions.h +++ b/src/mongo/db/pipeline/document_source_list_local_sessions.h @@ -84,8 +84,9 @@ public: return false; } - ReadConcernSupportResult supportsReadConcern(repl::ReadConcernLevel level) const { - return onlyReadConcernLocalSupported(kStageName, level); + ReadConcernSupportResult supportsReadConcern(repl::ReadConcernLevel level, + bool isImplicitDefault) const { + return onlyReadConcernLocalSupported(kStageName, level, isImplicitDefault); } void assertSupportsMultiDocumentTransaction() const { diff --git a/src/mongo/db/pipeline/document_source_merge.h b/src/mongo/db/pipeline/document_source_merge.h index f3c76be7e2f..54e9620793f 100644 --- a/src/mongo/db/pipeline/document_source_merge.h +++ b/src/mongo/db/pipeline/document_source_merge.h @@ -88,7 +88,8 @@ public: return false; } - ReadConcernSupportResult supportsReadConcern(repl::ReadConcernLevel level) const final { + ReadConcernSupportResult supportsReadConcern(repl::ReadConcernLevel level, + bool isImplicitDefault) const final { return { {level == repl::ReadConcernLevel::kLinearizableReadConcern, {ErrorCodes::InvalidOptions, diff --git a/src/mongo/db/pipeline/document_source_out.h b/src/mongo/db/pipeline/document_source_out.h index b01182ffcbd..140544897d1 100644 --- a/src/mongo/db/pipeline/document_source_out.h +++ b/src/mongo/db/pipeline/document_source_out.h @@ -67,7 +67,8 @@ public: return {Privilege(ResourcePattern::forExactNamespace(_foreignNss), actions)}; } - ReadConcernSupportResult supportsReadConcern(repl::ReadConcernLevel level) const final { + ReadConcernSupportResult supportsReadConcern(repl::ReadConcernLevel level, + bool isImplicitDefault) const final { return { {level == repl::ReadConcernLevel::kLinearizableReadConcern, {ErrorCodes::InvalidOptions, diff --git a/src/mongo/db/pipeline/document_source_plan_cache_stats.h b/src/mongo/db/pipeline/document_source_plan_cache_stats.h index 06aa28d908f..d72b0a22ac8 100644 --- a/src/mongo/db/pipeline/document_source_plan_cache_stats.h +++ b/src/mongo/db/pipeline/document_source_plan_cache_stats.h @@ -67,8 +67,9 @@ public: return false; } - ReadConcernSupportResult supportsReadConcern(repl::ReadConcernLevel level) const { - return onlyReadConcernLocalSupported(kStageName, level); + ReadConcernSupportResult supportsReadConcern(repl::ReadConcernLevel level, + bool isImplicitDefault) const { + return onlyReadConcernLocalSupported(kStageName, level, isImplicitDefault); } void assertSupportsMultiDocumentTransaction() const { diff --git a/src/mongo/db/pipeline/lite_parsed_document_source.h b/src/mongo/db/pipeline/lite_parsed_document_source.h index a504eeb9b3c..ceb33521bcc 100644 --- a/src/mongo/db/pipeline/lite_parsed_document_source.h +++ b/src/mongo/db/pipeline/lite_parsed_document_source.h @@ -192,7 +192,8 @@ public: /** * Verifies that this stage is allowed to run with the specified read concern level. */ - virtual ReadConcernSupportResult supportsReadConcern(repl::ReadConcernLevel level) const { + virtual ReadConcernSupportResult supportsReadConcern(repl::ReadConcernLevel level, + bool isImplicitDefault) const { return ReadConcernSupportResult::allSupportedAndDefaultPermitted(); } @@ -224,11 +225,11 @@ protected: << "multi-document transaction."); } - ReadConcernSupportResult onlySingleReadConcernSupported( - StringData stageName, - repl::ReadConcernLevel supportedLevel, - repl::ReadConcernLevel candidateLevel) const { - return {{candidateLevel != supportedLevel, + ReadConcernSupportResult onlySingleReadConcernSupported(StringData stageName, + repl::ReadConcernLevel supportedLevel, + repl::ReadConcernLevel candidateLevel, + bool isImplicitDefault) const { + return {{candidateLevel != supportedLevel && !isImplicitDefault, {ErrorCodes::InvalidOptions, str::stream() << "Aggregation stage " << stageName << " cannot run with a readConcern other than '" @@ -241,9 +242,10 @@ protected: } ReadConcernSupportResult onlyReadConcernLocalSupported(StringData stageName, - repl::ReadConcernLevel level) const { + repl::ReadConcernLevel level, + bool isImplicitDefault) const { return onlySingleReadConcernSupported( - stageName, repl::ReadConcernLevel::kLocalReadConcern, level); + stageName, repl::ReadConcernLevel::kLocalReadConcern, level, isImplicitDefault); } private: diff --git a/src/mongo/db/pipeline/lite_parsed_pipeline.cpp b/src/mongo/db/pipeline/lite_parsed_pipeline.cpp index 2e5ba95c7d7..437c7d17f5c 100644 --- a/src/mongo/db/pipeline/lite_parsed_pipeline.cpp +++ b/src/mongo/db/pipeline/lite_parsed_pipeline.cpp @@ -39,6 +39,7 @@ namespace mongo { ReadConcernSupportResult LiteParsedPipeline::supportsReadConcern( repl::ReadConcernLevel level, + bool isImplicitDefault, boost::optional<ExplainOptions::Verbosity> explain, bool enableMajorityReadConcern) const { // Start by assuming that we will support both readConcern and cluster-wide default. @@ -77,7 +78,7 @@ ReadConcernSupportResult LiteParsedPipeline::supportsReadConcern( if (!result.readConcernSupport.isOK() && !result.defaultReadConcernPermit.isOK()) { break; } - result.merge(spec->supportsReadConcern(level)); + result.merge(spec->supportsReadConcern(level, isImplicitDefault)); } return result; diff --git a/src/mongo/db/pipeline/lite_parsed_pipeline.h b/src/mongo/db/pipeline/lite_parsed_pipeline.h index be9601150e0..51303f3aa04 100644 --- a/src/mongo/db/pipeline/lite_parsed_pipeline.h +++ b/src/mongo/db/pipeline/lite_parsed_pipeline.h @@ -128,6 +128,7 @@ public: * Verifies that this pipeline is allowed to run with the specified read concern level. */ ReadConcernSupportResult supportsReadConcern(repl::ReadConcernLevel level, + bool isImplicitDefault, boost::optional<ExplainOptions::Verbosity> explain, bool enableMajorityReadConcern) const; |