diff options
author | Vishnu Kaushik <vishnu.kaushik@mongodb.com> | 2019-06-19 14:29:35 -0400 |
---|---|---|
committer | Vishnu Kaushik <vishnu.kaushik@mongodb.com> | 2019-06-19 14:30:22 -0400 |
commit | 8b0a7b102b92891818175358b0ca82a545105023 (patch) | |
tree | 5b8cf8a3a0a01f66f99e6aac99318a4d53d1ab18 /src/mongo/db | |
parent | 0194322119368dd4918212cd0a5108023748e534 (diff) | |
download | mongo-8b0a7b102b92891818175358b0ca82a545105023.tar.gz |
SERVER-41481 1 started new branch, added functionality for exhaustCursorId once again. Trying to kill the purple
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/dbmessage.h | 6 | ||||
-rw-r--r-- | src/mongo/db/service_entry_point_common.cpp | 18 |
2 files changed, 20 insertions, 4 deletions
diff --git a/src/mongo/db/dbmessage.h b/src/mongo/db/dbmessage.h index f6281c3614c..c4c8bd3b243 100644 --- a/src/mongo/db/dbmessage.h +++ b/src/mongo/db/dbmessage.h @@ -445,6 +445,12 @@ Message makeGetMoreMessage(StringData ns, long long cursorId, int nToReturn, int struct DbResponse { Message response; // If empty, nothing will be returned to the client. std::string exhaustNS; // Namespace of cursor if exhaust mode, else "". + + /** + * Cursor ID when running on exhaust mode. Defaults to '0', indicating + * that the cursor is exhausted. + */ + long long exhaustCursorId = 0; }; /** diff --git a/src/mongo/db/service_entry_point_common.cpp b/src/mongo/db/service_entry_point_common.cpp index 89076c67f13..c0d131852bc 100644 --- a/src/mongo/db/service_entry_point_common.cpp +++ b/src/mongo/db/service_entry_point_common.cpp @@ -1006,11 +1006,21 @@ DbResponse receivedCommands(OperationContext* opCtx, return {}; // Don't reply. } - auto response = replyBuilder->done(); - CurOp::get(opCtx)->debug().responseLength = response.header().dataLen(); + DbResponse dbResponse; + + if (OpMsg::isFlagSet(message, OpMsg::kExhaustSupported)) { + auto responseObj = replyBuilder->getBodyBuilder().asTempObj(); + auto cursorObj = responseObj.getObjectField("cursor"); + if (responseObj.getField("ok").trueValue() && !cursorObj.isEmpty()) { + dbResponse.exhaustNS = cursorObj.getField("ns").String(); + dbResponse.exhaustCursorId = cursorObj.getField("id").numberLong(); + } + } + + dbResponse.response = replyBuilder->done(); + CurOp::get(opCtx)->debug().responseLength = dbResponse.response.header().dataLen(); - // TODO exhaust - return DbResponse{std::move(response)}; + return dbResponse; } DbResponse receivedQuery(OperationContext* opCtx, |