diff options
author | Jason Chan <jason.chan@mongodb.com> | 2020-12-09 22:01:43 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-12-15 20:54:15 +0000 |
commit | bb3279a62dfc65bdafa5164a7ce85c8322b4757b (patch) | |
tree | ae7c7005d802795303750a8c8f068bf47505aaff /src/mongo/client | |
parent | 0c132588e9907c7b123f986a61c3a43cd087381f (diff) | |
download | mongo-bb3279a62dfc65bdafa5164a7ce85c8322b4757b.tar.gz |
SERVER-50985 Tenant collection cloner query must use readConcern majority
Diffstat (limited to 'src/mongo/client')
-rw-r--r-- | src/mongo/client/dbclient_cursor.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/mongo/client/dbclient_cursor.cpp b/src/mongo/client/dbclient_cursor.cpp index 10e7ad1adf9..54757f32b68 100644 --- a/src/mongo/client/dbclient_cursor.cpp +++ b/src/mongo/client/dbclient_cursor.cpp @@ -143,9 +143,12 @@ Message DBClientCursor::_assembleInit() { // Legacy queries don't handle term. qr.getValue()->setReplicationTerm(replTerm.numberLong()); } + // Legacy queries don't handle readConcern. + // We prioritize the readConcern parsed from the query object over '_readConcernObj'. if (auto readConcern = query[repl::ReadConcernArgs::kReadConcernFieldName]) { - // Legacy queries don't handle readConcern. qr.getValue()->setReadConcern(readConcern.Obj()); + } else if (_readConcernObj) { + qr.getValue()->setReadConcern(*_readConcernObj); } BSONObj cmd = _nsOrUuid.uuid() ? qr.getValue()->asFindCommandWithUuid() : qr.getValue()->asFindCommand(); @@ -153,12 +156,6 @@ Message DBClientCursor::_assembleInit() { // QueryRequest doesn't handle $readPreference. cmd = BSONObjBuilder(std::move(cmd)).append(readPref).obj(); } - if (!cmd.hasField(repl::ReadConcernArgs::kReadConcernFieldName) && _readConcernObj) { - cmd = BSONObjBuilder(std::move(cmd)) - .append(repl::ReadConcernArgs::kReadConcernFieldName, *_readConcernObj) - .obj(); - } - return assembleCommandRequest(_client, ns.db(), opts, std::move(cmd)); } // else use legacy OP_QUERY request. |