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

BtreeKeyGenerator::_extractNextElement() uassert message exceeds 16mb BSON document limit when added to a command result

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.3.1
    • Component/s: Storage
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v4.2
    • Sprint:
      Execution Team 2019-11-18
    • Linked BF Score:
      11

      Description

      When we attempt to index a document that is ambiguous for the key pattern {‘a.0’: 1}, BtreeKeyGenerator::_extractNextElement() includes the contents of the array field in the uassert error message, with error code 16746. When the command processing subsystem converts this UserAssertion into a Status for the createIndexes command result, the result may exceed the 16 MB BSON document limit, leading to a different error code BSONObjectTooLarge returned in the final result. This obscures the original source of the indexing error.

      To reproduce:

      // Add a small document first. We cannot transmit a document larger than the 16mb over the wire.
      const dupDoc = {a: [{'0': 1}]};
      t.save(dupDoc);
       
      // This extends the array with nulls before append the requested integer.
      // The 1,5000,000 constant is based on a limit defined in path_support.h
      t.update({}, {$set: {'a.1500001': 1}});
       
      // This should fail with an error code of 16746 instead of BSONObjectTooLarge.
      t.ensureIndex({'a.0': 1});
      

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: