Trying to insert a custom _id value larger than 800 bytes should raise an exception.

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Field values larger than 800 bytes are allowed in MongoDB but they can't be indexed. If you insert a document with a large value for an indexed field you will see a log message similar to:

      Thu Sep  1 10:32:34 [conn6]  bigid.foo Btree::insert: key too large to index, skipping bigid.foo.$_id_ 862 { : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx..." }
      

      See the attached script for a repro. If you then try to query on that field the document won't be returned since it's not in the index. This may be fine for other fields but it causes a lot of problems with large _id values. Tools that walk the _id index (mongodump is a great example) will skip these documents.

        1. big_id.js
          0.3 kB
          Bernie Hackett

            Assignee:
            Unassigned
            Reporter:
            Bernie Hackett
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: