summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlake Oler <blake.oler@mongodb.com>2019-04-24 10:34:01 -0400
committerBlake Oler <blake.oler@mongodb.com>2019-05-08 12:16:26 -0400
commitf25d7d70ca9b2c0282640779adf5c690c0368f1b (patch)
treee9d75b5678843d50c4c6c91e8942006adc5233a7
parent3b00dc385a99b576cee4d0f58d8a80e296b4b09c (diff)
downloadmongo-f25d7d70ca9b2c0282640779adf5c690c0368f1b.tar.gz
SERVER-40792 Create error details if doesn't already exist when handling WouldChangeOwningShard error
-rw-r--r--src/mongo/s/commands/cluster_write_cmd.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/mongo/s/commands/cluster_write_cmd.cpp b/src/mongo/s/commands/cluster_write_cmd.cpp
index b4b7660910c..5793d3a4d78 100644
--- a/src/mongo/s/commands/cluster_write_cmd.cpp
+++ b/src/mongo/s/commands/cluster_write_cmd.cpp
@@ -276,7 +276,11 @@ bool handleWouldChangeOwningShardError(OperationContext* opCtx,
"Update operation was converted into a distributed transaction because the "
"document being updated would move shards and that transaction failed");
}
-
+ if (!response->isErrDetailsSet() || !response->getErrDetails().back()) {
+ auto error = stdx::make_unique<WriteErrorDetail>();
+ error->setIndex(0);
+ response->addToErrDetails(error.release());
+ }
response->getErrDetails().back()->setStatus(status);
auto txnRouterForAbort = TransactionRouter::get(opCtx);