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

Retryable writes can return the wrong results when using a MongoClient before and after a fork()

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.10
    • Affects Version/s: 3.9
    • Component/s: None
    • Labels:
      None

      Since upgrading to pymongo 3.9 we are seeing documents that are failing to insert or update using the following pymongo calls:

      coll.update_one(flattened_json_data, {{color:#6a8759}'$set': flattened_json_data}, upsert=True)

      coll.find_one_and_update(query, update, upsert=True, projection=projection, return_document=ReturnDocument.AFTER)

      However, pymongo seems to be returning successfully even when documents aren't inserted or updated.

      We believe this might be due to the fact that we are not using the MongoClient in a fork safe way. We spawn threads and processes that all use the same shared MongoClient connection and sometimes causes the error described here: https://jira.mongodb.org/browse/PYTHON-1992?jql=text%20~%20%22Cannot%20start%20transaction%20on%20session%22

      However, is it possible that due to the issues with our application logic's unsafe use of the MongoClient, pymongo could return successfully without having actually successfully completed the insertion/update?

      We have since fixed our application logic and have stopped seeing the error described in the linked PBI. We are hoping the issue of failed inserts will be fixed as well.

       

            Assignee:
            shane.harvey@mongodb.com Shane Harvey
            Reporter:
            kevin.boehme@aruplab.com Kevin Boehme
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: