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

Raise an actionable error message when bulk_write/insert_many retryWrites fails due to using an unsupported storage engine or standalone

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 4.7
    • Affects Version/s: 3.9
    • Component/s: API, Spec Comp
    • Labels:
    • Environment:
      Pymongo: 3.9.0
      MongoDB: 4.2.1, sharded cluster
      OS: Scientific Linux release 7.7
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      insert_many() fails on inserts when connected to mongos. The same code completes successfully when using standalone instance. This seems to be python module issue.  insert_many in ruby gem works as expected.

      Earlier version of the module (3.7) also worked fine, but I can't downgrade due to a non-related issue.

      Here is a minimal example demonstrating the issue:

      from pymongo import MongoClient
      client = MongoClient(host = "localhost", port = 27017)
      db = client["test"]
      coll = db["coll"]
      data = [\{"a":1},\{"a":2}]
      coll = coll.insert_many(data)

       

      Output from the code:

      {{{{$ python3 ./test.py }}}}
      {{Traceback (most recent call last):}}
      {{  File "./test.py", line 7, in <module>}}
      {{    coll = coll.insert_many(data)}}
      {{  File "/usr/local/lib64/python3.6/site-packages/pymongo/collection.py", line 758, in insert_many}}
      {{    blk.execute(write_concern, session=session)}}
      {{  File "/usr/local/lib64/python3.6/site-packages/pymongo/bulk.py", line 511, in execute}}
      {{    return self.execute_command(generator, write_concern, session)}}
      {{  File "/usr/local/lib64/python3.6/site-packages/pymongo/bulk.py", line 349, in execute_command}}
      {{    _raise_bulk_write_error(full_result)}}
      {{  File "/usr/local/lib64/python3.6/site-packages/pymongo/bulk.py", line 140, in _raise_bulk_write_error}}
      {{    raise BulkWriteError(full_result)}}
      {{pymongo.errors.BulkWriteError: batch op errors occurred}}

            Assignee:
            steve.silvester@mongodb.com Steve Silvester
            Reporter:
            jacek.radzikowski@gmail.com Jacek Radzikowski
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: