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

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor - P4 Minor - P4
    • 4.7
    • 3.9
    • API, Spec Comp
    • Pymongo: 3.9.0
      MongoDB: 4.2.1, sharded cluster
      OS: Scientific Linux release 7.7

    Description

      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}}

      Attachments

        Activity

          People

            Unassigned Unassigned
            jacek.radzikowski@gmail.com Jacek Radzikowski
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: