diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2017-06-13 17:02:28 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2017-06-19 09:51:48 -0400 |
commit | 0d7f9a01b1ae168b8adfc02bb1eb0c1616138d38 (patch) | |
tree | a68c495ce22052ed7f77d8f2af0f5b80c5aabab1 /src/mongo | |
parent | 93792040144f9c6197899627290b641073c549c4 (diff) | |
download | mongo-0d7f9a01b1ae168b8adfc02bb1eb0c1616138d38.tar.gz |
SERVER-28754 Make BatchWriteExec on mongos send txnNumber/stmtId in the explicit form to shards
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/s/write_ops/batch_write_op.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/mongo/s/write_ops/batch_write_op.cpp b/src/mongo/s/write_ops/batch_write_op.cpp index ec2e7391c0e..440f4a4b40b 100644 --- a/src/mongo/s/write_ops/batch_write_op.cpp +++ b/src/mongo/s/write_ops/batch_write_op.cpp @@ -406,6 +406,12 @@ void BatchWriteOp::buildBatchRequest(const TargetedWriteBatch& targetedBatch, request->setShouldBypassValidation(_clientRequest.shouldBypassValidation()); const auto batchType = _clientRequest.getBatchType(); + const auto batchTxnNum = _clientRequest.getTxnNum(); + + boost::optional<std::vector<int32_t>> stmtIdsForOp; + if (batchTxnNum) { + stmtIdsForOp.emplace(); + } for (auto& targetedWrite : targetedBatch.getWrites()) { const WriteOpRef& writeOpRef = targetedWrite->writeOpRef; @@ -430,6 +436,10 @@ void BatchWriteOp::buildBatchRequest(const TargetedWriteBatch& targetedBatch, MONGO_UNREACHABLE; } + if (stmtIdsForOp) { + stmtIdsForOp->push_back(_clientRequest.getStmtIdForWriteAt(writeOpRef.first)); + } + // TODO: We can add logic here to allow aborting individual ops // if ( NULL == response ) { // ->responses.erase( it++ ); @@ -452,6 +462,11 @@ void BatchWriteOp::buildBatchRequest(const TargetedWriteBatch& targetedBatch, } request->setShardVersion(targetedBatch.getEndpoint().shardVersion); + + if (batchTxnNum) { + request->setTxnNum(batchTxnNum); + request->setStmtIds(std::move(stmtIdsForOp)); + } } void BatchWriteOp::noteBatchResponse(const TargetedWriteBatch& targetedBatch, |