Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-64918

Add a log entry if OpMsgRequest.body is bigger than BSONObjMaxInternalSize

    XMLWordPrintableJSON

Details

    • Query Execution
    • Fully Compatible
    • QE 2023-06-12, QE 2023-06-26

    Description

      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();
      }());
      

      Attachments

        Activity

          People

            kristina.znam@mongodb.com Kristina Znam (Inactive)
            mohammad.dashti@mongodb.com Mohammad Dashti (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: