Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-1365

About DocumentTooLarge

    • Type: Icon: Task Task
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 3.4, 3.5
    • Component/s: Error Handling
    • None

      when I do insert_one operation with object `

      {"key": "1" * 1024 * 1024 * 16}

      `

      I will get an error like:

      ```
      pymongo.errors.WriteError: object to insert too large. size in bytes: 16777248, max size: 16777216
      ```

      then I doinsert_one with `

      {"key": "1" * 1024 * 1024 * 18}

      `

      I will get:

      ```
      pymongo.errors.DocumentTooLarge: BSON document too large (18874451 bytes) - the connected server supports BSON document sizes up to 16793598 bytes.
      ```

      I mean, There are two Exceptions with one situation( document is too large). That seems strange.

      and there is a similar case on insert_many.

      when I set a big document as `doc1`, and do `insert_many([doc1, {}])`, I will get `pymongo.errors.DocumentTooLarge`. That seems ok. but when I do `insert_many([{}, doc1])`, I did get `pymongo.errors.AutoReconnect`.

      Then I read the source code of pymongo. I do know what is going on now. I just think, could it be better when I meet one kind of situation, I will get only one exception.

            Assignee:
            Unassigned Unassigned
            Reporter:
            wjy0203@175game.com Martin Wu
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: