[SERVER-36565] Killing a session with a transaction can cause the thread to throw WriteConflictError Created: 09/Aug/18  Updated: 29/Oct/23  Resolved: 13/Aug/18

Status: Closed
Project: Core Server
Component/s: Replication
Affects Version/s: None
Fix Version/s: 4.0.3, 4.1.2

Type: Bug Priority: Major - P3
Reporter: Janna Golden Assignee: Janna Golden
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File auto_retry_transaction.js     File multi_statement_transaction_kill_sessions_atomicity_isolation.js    
Issue Links:
Backports
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.0
Sprint: Sharding 2018-08-27
Participants:
Linked BF Score: 45

 Description   

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.



 Comments   
Comment by Githook User [ 28/Aug/18 ]

Author:

{'name': 'jannaerin', 'email': 'golden.janna@gmail.com', 'username': 'jannaerin'}

Message: SERVER-36565 Check if txn in progress or aborted when executing write commands

(cherry picked from commit d3941824b4473898bf987c7db381a84879d33c27)
Branch: v4.0
https://github.com/mongodb/mongo/commit/a507d534f2e15afb648e095be1b9e5f155ab7872

Comment by Githook User [ 13/Aug/18 ]

Author:

{'name': 'jannaerin', 'email': 'golden.janna@gmail.com', 'username': 'jannaerin'}

Message: SERVER-36565 Check if txn in progress or aborted when executing write commands
Branch: master
https://github.com/mongodb/mongo/commit/d3941824b4473898bf987c7db381a84879d33c27

Generated at Thu Feb 08 04:43:29 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.