[SERVER-33669] Stepdown and shutdown should abort all uncommitted transactions Created: 05/Mar/18  Updated: 29/Oct/23  Resolved: 20/Mar/18

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: None
Fix Version/s: 3.7.4

Type: Bug Priority: Major - P3
Reporter: Tess Avitabile (Inactive) Assignee: Tess Avitabile (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-33672 make killSessionsLocal() kill any mat... Closed
Duplicate
is duplicated by SERVER-33550 Abort transactions on stepdown Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

The following hangs at shutdown:

(function() {
    const rst = new ReplSetTest({nodes: 1});
    rst.startSet();
    rst.initiate();
    const session = rst.getPrimary().getDB("test").getMongo().startSession();
    const db = session.getDatabase("test");
 
    for (let i = 0; i < 4; i++) {
        assert.commandWorked(db.coll.insert({_id: i}, {writeConcern: {w: "majority"}}));
    }
 
    const res = assert.commandWorked(db.runCommand(
        {find: "coll", batchSize: 2, readConcern: {level: "snapshot"}, txnNumber: NumberLong(0)}));
 
    rst.stopSet();
}());

Sprint: Storage NYC 2018-03-26
Participants:

 Comments   
Comment by Githook User [ 20/Mar/18 ]

Author:

{'email': 'tess.avitabile@mongodb.com', 'name': 'Tess Avitabile', 'username': 'tessavitabile'}

Message: SERVER-33669 Stepdown and shutdown should abort all uncommitted transactions
Branch: master
https://github.com/mongodb/mongo/commit/374f14d984da357c943098735e7e6d13f250675a

Comment by Eric Milkie [ 07/Mar/18 ]

That is a good point to bring up.
The code details are:

  • At shutdown (mongod and mongos), ServiceContext::setKillAllOperations() is called.
  • At stepdown time, ServiceContext::killAllUserOperations() is called.

These functions are very similar. Both loop through all Clients and call killOperation() on each Client (or "isFromUserConnection client" in the case of stepdown).

Therefore, we should take care to modify both loops (or better yet, combine the two functions into using one shared loop), in order to find and kill all Stashed operations that are not associated with a Client.

In addition, we should make a pass through the entire codebase to see if there are any other loop-through-all-clients, to consider if they should be looking at Stashed transactions as well.

Comment by Andy Schwerin [ 07/Mar/18 ]

Does stepDown need to take similar action?

Comment by Eric Milkie [ 05/Mar/18 ]

When shutdown aborts all in-progress ops, it needs to kill all sessions as well. The act of killing sessions will free up all stashed transactions, as part of the Local Snapshot Read Support Mechanisms project.

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