summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorRuoxin Xu <ruoxin.xu@mongodb.com>2020-08-17 12:58:31 +0100
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-11-26 12:49:08 +0000
commit653efb29e7357524f604e274c786e4ad73d43db2 (patch)
treed61d719b993da5f686da13def178659dfd45f2d2 /src/mongo
parent6588e91769e070e60508ced4412e7db8f38f153c (diff)
downloadmongo-653efb29e7357524f604e274c786e4ad73d43db2.tar.gz
SERVER-50267 Set output limit for rawMongoProgramOutput()
(cherry picked from commit 30acdea3aa54dab658cb76908a8cd9bf35e7762f)
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/shell/shell_utils_launcher.cpp9
-rw-r--r--src/mongo/shell/shell_utils_launcher.h1
2 files changed, 8 insertions, 2 deletions
diff --git a/src/mongo/shell/shell_utils_launcher.cpp b/src/mongo/shell/shell_utils_launcher.cpp
index 7537d710165..7397550b053 100644
--- a/src/mongo/shell/shell_utils_launcher.cpp
+++ b/src/mongo/shell/shell_utils_launcher.cpp
@@ -757,8 +757,15 @@ bool wait_for_pid(ProcessId pid, bool block = true, int* exit_code = NULL) {
#endif
}
+// Output up to BSONObjMaxUserSize characters of the most recent log output in order to
+// avoid hitting the 16MB size limit of a BSONObject.
BSONObj RawMongoProgramOutput(const BSONObj& args, void* data) {
- return BSON("" << programOutputLogger.str());
+ std::string programLog = programOutputLogger.str();
+ std::size_t sz = programLog.size();
+ const string& outputStr =
+ sz > BSONObjMaxUserSize ? programLog.substr(sz - BSONObjMaxUserSize) : programLog;
+
+ return BSON("" << outputStr);
}
BSONObj ClearRawMongoProgramOutput(const BSONObj& args, void* data) {
diff --git a/src/mongo/shell/shell_utils_launcher.h b/src/mongo/shell/shell_utils_launcher.h
index c93e77ec34a..b0429893eb4 100644
--- a/src/mongo/shell/shell_utils_launcher.h
+++ b/src/mongo/shell/shell_utils_launcher.h
@@ -66,7 +66,6 @@ void installShellUtilsLauncher(Scope& scope);
class ProgramOutputMultiplexer {
public:
void appendLine(int port, ProcessId pid, const std::string& name, const std::string& line);
- /** @return up to 100000 characters of the most recent log output. */
std::string str() const;
void clear();