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

Inserting deeply-nested documents should fail with error

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.4.4, 3.5.5
    • Component/s: Security, Write Ops
    • Labels:
      None
    • Backwards Compatibility:
      Major Change
    • Backport Completed:
    • Backport Requested:
      v3.4
    • Sprint:
      Query 2017-01-23, Query 2017-02-13, Query 2017-03-27
    • Case:
    • Linked BF Score:
      0

      Description

      From the MongoDB Limits and Thresholds docs page:

      Nested Depth for BSON Documents

      MongoDB supports no more than 100 levels of nesting for BSON documents.

      The server should fail insertion of these documents with an error returned to the user. This would make the server's behavior consistent with the documentation.

      Furthermore, if code in the server can assume that the nesting limit is fairly small, and the server can assert that the stack is of some known minimum size at time of process start, then recursive algorithms in the server can executed safely on these documents without concern of stack overflow.

      To reproduce, run the following shell snippet.

      function makeNestObj(depth){
          toret = {s : 1};
          for(i = 1; i < depth; i++){
              toret = {s : toret};
          }
          return toret;
      }
      db.foo.drop();
      assert.writeError(db.foo.insert(makeNestObj(101)));  // Currently fails, should pass when this ticket is resolved.
      

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                13 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: