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

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.3.1, 4.2.3
    • Affects Version/s: None
    • Component/s: Storage
    • None
    • Fully Compatible
    • ALL
    • v4.2
    • Execution Team 2019-11-18
    • 11

      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}]};
      // 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});

            benety.goh@mongodb.com Benety Goh
            benety.goh@mongodb.com Benety Goh
            0 Vote for this issue
            0 Start watching this issue