-
Type: Improvement
-
Resolution: Fixed
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: None
-
Query Execution
-
Fully Compatible
-
QE 2023-06-12, QE 2023-06-26
-
(copied to CRM)
When creating the body of OpMsgRequest it's possible that the combination of body, extraFields and $db goes beyond BSONObjMaxInternalSize. In this case, currently, only an assertion failure is issued. However, to improve the situation and help our support team with more useful data, we'd better log the size break-down of these fields (and even include the truncated values for them):
Here's a suggested change for here:
static std::string compactStr(const std::string& input) { if (input.length() > 2024) { return input.substr(0, 1000) + " ... " + input.substr(input.length() - 1000); } return input; } request.body = ([&] { BSONObjBuilder bodyBuilder(std::move(body)); bodyBuilder.appendElements(extraFields); bodyBuilder.append("$db", db); if (bodyBuilder.len() > BSONObjMaxInternalSize) { warning() << "Request body exceeded limit with body.objsize() = " << body.objsize() << ", db.size() = " << db.size() << ", extraFields.objsize() = " << extraFields.objsize() << ", body.toString() = " << compactStr(body.toString()) << ", db = " << db << ", extraFields.toString() = " << compactStr(extraFields.toString()); } return bodyBuilder.obj(); }());