Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-34059

DuplicateKeyError aborts transaction

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Replication
    • None
    • Replication
    • ALL

      I'm trying to test how drivers will handle error cases within multi-statement transactions. I perform the following with my prototype of PyMongo that supports transactions:

      session = client.start_session()
      session.start_transaction()
      collection.insert_one({'_id': 1}, session=session)
      try:
          collection.insert_one({'_id': 1}, session=session)
      except Exception as exc:
          print(exc)
      collection.insert_one({'_id': 1}, session=session)
      session.commit_transaction()
      

      It appears (based on debugging) that the transaction includes the document {_id: 1} after the first insert, and the second insert not only causes a duplicate key error, it also aborts the transaction. Therefore the third insert succeeds (outside of any transaction), and the commit_transaction fails with code 125, errmsg "Transaction isn't in progress."

            Assignee:
            backlog-server-repl [DO NOT USE] Backlog - Replication Team
            Reporter:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Votes:
            0 Vote for this issue
            Watchers:
            18 Start watching this issue

              Created:
              Updated:
              Resolved: