diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2022-03-03 17:30:22 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-03-03 18:35:23 +0000 |
commit | c46cc6378e20219b1e98947dddc9cea1012d25b2 (patch) | |
tree | cf6d4262790e1bad5f5e89a32e5ccb8dde64702f /src/mongo/db | |
parent | 4f3626ff4486e672569699dfde1cc0ae8c54d348 (diff) | |
download | mongo-c46cc6378e20219b1e98947dddc9cea1012d25b2.tar.gz |
SERVER-64078 Only truncate error messages if they are bigger than 1M
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/commands/write_commands.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/mongo/db/commands/write_commands.cpp b/src/mongo/db/commands/write_commands.cpp index 0b671d5a8aa..d562d21a00e 100644 --- a/src/mongo/db/commands/write_commands.cpp +++ b/src/mongo/db/commands/write_commands.cpp @@ -340,12 +340,26 @@ boost::optional<write_ops::WriteError> generateError(OperationContext* opCtx, if (ErrorCodes::isInterruption(*overwrittenStatus)) { uassertStatusOK(*overwrittenStatus); } + + // Tenant migration errors, similarly to migration errors consume too much space in the + // ordered:false responses and get truncated. Since the call to + // 'handleTenantMigrationConflict' above replaces the original status, we need to manually + // truncate the new reason if the original 'status' was also truncated. + if (status.reason().empty()) { + overwrittenStatus = overwrittenStatus->withReason(""); + } } constexpr size_t kMaxErrorReasonsToReport = 1; - if (numErrors >= kMaxErrorReasonsToReport) - overwrittenStatus = - overwrittenStatus ? overwrittenStatus->withReason("") : status.withReason(""); + constexpr size_t kMaxErrorSizeToReportAfterMaxReasonsReached = 1024 * 1024; + + if (numErrors > kMaxErrorReasonsToReport) { + size_t errorSize = + overwrittenStatus ? overwrittenStatus->reason().size() : status.reason().size(); + if (errorSize > kMaxErrorSizeToReportAfterMaxReasonsReached) + overwrittenStatus = + overwrittenStatus ? overwrittenStatus->withReason("") : status.withReason(""); + } if (overwrittenStatus) return write_ops::WriteError(index, std::move(*overwrittenStatus)); |