diff options
author | jannaerin <golden.janna@gmail.com> | 2019-01-28 17:19:47 -0500 |
---|---|---|
committer | jannaerin <golden.janna@gmail.com> | 2019-01-30 10:46:00 -0500 |
commit | 186ebd7815238c15f1e5599da6a736e0e74f70ed (patch) | |
tree | 08f3b693449a949d0fb35f4e6b0d1a0516d759fa /src | |
parent | 2b4514bdf69eecee3e90bb4ccfa6cba7e5f09a8a (diff) | |
download | mongo-186ebd7815238c15f1e5599da6a736e0e74f70ed.tar.gz |
SERVER-12947 Don't use MultipleErrorsPath if all errors are the same
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/s/write_ops/write_op.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/mongo/s/write_ops/write_op.cpp b/src/mongo/s/write_ops/write_op.cpp index 56e2ca92fc9..725f9d9a891 100644 --- a/src/mongo/s/write_ops/write_op.cpp +++ b/src/mongo/s/write_ops/write_op.cpp @@ -118,10 +118,21 @@ static bool isRetryErrCode(int errCode) { errCode == ErrorCodes::CannotImplicitlyCreateCollection; } +static bool errorsAllSame(const vector<ChildWriteOp const*>& errOps) { + auto errCode = errOps.front()->error->toStatus().code(); + if (std::all_of(++errOps.begin(), errOps.end(), [errCode](const ChildWriteOp* errOp) { + return errOp->error->toStatus().code() == errCode; + })) { + return true; + } + + return false; +} + // Aggregate a bunch of errors for a single op together static void combineOpErrors(const vector<ChildWriteOp const*>& errOps, WriteErrorDetail* error) { - // Special case single response - if (errOps.size() == 1) { + // Special case single response or all errors are the same + if (errOps.size() == 1 || errorsAllSame(errOps)) { errOps.front()->error->cloneTo(error); return; } |