summaryrefslogtreecommitdiff
path: root/src
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 14:17:01 +0000
commit19aaba5321fc640337c22aac775e279c49c5b709 (patch)
treeacabee63e4bcf7cdf6ebe90ba1419d6083ffbf7a /src
parent58c8bb3b1b1e72d42b7ad2bb203e63271745401c (diff)
downloadmongo-19aaba5321fc640337c22aac775e279c49c5b709.tar.gz
SERVER-50267 Set output limit for rawMongoProgramOutput()
(cherry picked from commit 30acdea3aa54dab658cb76908a8cd9bf35e7762f)
Diffstat (limited to 'src')
-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 f77f255dd50..57b99ab5977 100644
--- a/src/mongo/shell/shell_utils_launcher.cpp
+++ b/src/mongo/shell/shell_utils_launcher.cpp
@@ -744,8 +744,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 aa85e056bad..7632cf316fb 100644
--- a/src/mongo/shell/shell_utils_launcher.h
+++ b/src/mongo/shell/shell_utils_launcher.h
@@ -67,7 +67,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();