Running abortTransaction shortly after the initial transaction op can erroneously return "NoSuchTransaction"

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: 7.0.18
    • Component/s: None
    • None
    • ALL
    • Hide
      1. Start Docker.
      2. Unzip mongo-context-cancel-repro-mattd.zip
      3. Run MAX_RETRY_COUNT=5 ./run.sh
      Show
      Start Docker. Unzip mongo-context-cancel-repro-mattd.zip Run MAX_RETRY_COUNT=5 ./run.sh
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Running "abortTransaction" shortly after running the first operation in a new transaction can fail to abort the transaction, leaving the transaction open until it times out on the server (transactionLifetimeLimitSeconds, default 60 seconds). During that time, any attempt to modify the same documents in a transaction will result in a write conflict error like

      (WriteConflict) Caused by :: Write conflict during plan execution and yielding is disabled. :: Please retry your operation or multi-document transaction.

      That scenario can happen when using a driver's WithTransaction API and cancelling the first operation while the driver is reading the response. In that case, the driver will select a different connection and run "abortTransaction". Under certain timing conditions, the "abortTransaction" operation will fail with an error like

      (NoSuchTransaction) Given transaction number 55 does not match any in-progress transactions. The active transaction number is 54

      However, the transaction is eventually created and left open because the attempt to abort it failed.

      See mongo-context-cancel-repro-mattd.zip for a full repro setup using Docker. See client.log, diagnostic.data.zip, and mongod.log.zip for logs collected from running the repro. See HELP-84441 for the original customer report and background. See GODRIVER-3737 for a proposed mitigation in the Go Driver.

        1. client.log
          5.01 MB
        2. diagnostic.data.zip
          1.02 MB
        3. mongo-context-cancel-repro-mattd.zip
          17 kB
        4. mongod.log.zip
          15.55 MB

            Assignee:
            Unassigned
            Reporter:
            Matt Dale
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: