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

Killing a session with a transaction can cause the thread to throw WriteConflictError

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.0.3, 4.1.2
    • Affects Version/s: None
    • Component/s: Replication
    • Labels:
    • Fully Compatible
    • ALL
    • v4.0
    • Sharding 2018-08-27
    • 45

      When killSessions is called on a session running a transaction, the transaction is aborted. The command that’s running can return a WriteConflict error that is not labeled with `TransientTransactionError` if the transaction is aborted while a write command is running, causing the thread to throw down the line. I’ve reproduced this with an `update` command in the concurrency suite - if there is a writeConflict caught here, we then check if we’re in a transaction in `handleError()` here . We don’t check if we’ve aborted a transaction though, so we would not throw here in this case, and instead would return the error and not catch the it in writeCommands::run() as we should be doing.

      We can also hit the invariant here for the same reason (if the transaction was aborted slightly earlier).

      We should check if the transaction was aborted and should also look into if the other places we call `inMultiDocumenTransaction()` need to be changed as well.

            janna.golden@mongodb.com Janna Golden
            janna.golden@mongodb.com Janna Golden
            0 Vote for this issue
            7 Start watching this issue