summaryrefslogtreecommitdiff
path: root/src/mongo/executor/async_transaction_rpc.h
diff options
context:
space:
mode:
authorGeorge Wangensteen <george.wangensteen@mongodb.com>2023-03-13 16:00:53 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-03-13 18:43:50 +0000
commit38d850fc76000fe64264a1c034df02f4c6a0affe (patch)
treee24ffbfffe7b74d0c921f3169dde269a75beec09 /src/mongo/executor/async_transaction_rpc.h
parentfbf9372bbf3eb705b38108964a39ab78c3439c4e (diff)
downloadmongo-38d850fc76000fe64264a1c034df02f4c6a0affe.tar.gz
SERVER-72082 Process transaction metadata via the TxnRouter when using AsyncRPC::sendTxnCommand
Diffstat (limited to 'src/mongo/executor/async_transaction_rpc.h')
-rw-r--r--src/mongo/executor/async_transaction_rpc.h17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/mongo/executor/async_transaction_rpc.h b/src/mongo/executor/async_transaction_rpc.h
index 56f438e3f3b..5ec4cc85370 100644
--- a/src/mongo/executor/async_transaction_rpc.h
+++ b/src/mongo/executor/async_transaction_rpc.h
@@ -69,10 +69,19 @@ ExecutorFuture<AsyncRPCResponse<typename CommandType::Reply>> sendTxnCommand(
return swResponse;
}
if (swResponse.isOK()) {
- // TODO (SERVER-72082): Make sure TxnResponseMetadata is appended to the BSON
- // that we are passing into 'processParticipantResponse'.
- txnRouter.processParticipantResponse(
- opCtx, shardId, swResponse.getValue().response.toBSON());
+ ReplyType reply = swResponse.getValue();
+ GenericReplyFields gens = reply.genericReplyFields;
+ // The TransactionRouter expects a raw-BSON command-response
+ // in its API for processing transaction metadata. The async_rpc API
+ // doesn't expose the raw-BSON of the response in the case of command-success,
+ // so we construct a fake one for now to appease the TxnRouter API.
+ auto fakeResponseObj = [&] {
+ BSONObjBuilder bob;
+ gens.stable.serialize(&bob);
+ gens.unstable.serialize(&bob);
+ return bob.obj();
+ }();
+ txnRouter.processParticipantResponse(opCtx, shardId, fakeResponseObj);
} else {
auto extraInfo = swResponse.getStatus().template extraInfo<AsyncRPCErrorInfo>();
if (extraInfo->isRemote()) {