From f25d7d70ca9b2c0282640779adf5c690c0368f1b Mon Sep 17 00:00:00 2001 From: Blake Oler Date: Wed, 24 Apr 2019 10:34:01 -0400 Subject: SERVER-40792 Create error details if doesn't already exist when handling WouldChangeOwningShard error --- src/mongo/s/commands/cluster_write_cmd.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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(); + error->setIndex(0); + response->addToErrDetails(error.release()); + } response->getErrDetails().back()->setStatus(status); auto txnRouterForAbort = TransactionRouter::get(opCtx); -- cgit v1.2.1