[SERVER-33671] Bumping txnNumber does not clear stashed transaction resources Created: 05/Mar/18  Updated: 16/Mar/18  Resolved: 16/Mar/18

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

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

Issue Links:
Duplicate
duplicates SERVER-33432 Implicit transaction abort Closed
Operating System: ALL
Steps To Reproduce:

(function() {
    const rst = new ReplSetTest({nodes: 1});
    rst.startSet();
    rst.initiate();
    const session = rst.getPrimary().getDB("test").getMongo().startSession();
    const db1 = session.getDatabase("test1");
    const db2 = session.getDatabase("test2");
 
    // Populate two collections in different databases.
    for (let i = 0; i < 4; i++) {
        assert.commandWorked(db1.coll.insert({_id: i}, {writeConcern: {w: "majority"}}));
        assert.commandWorked(db2.coll.insert({_id: i}, {writeConcern: {w: "majority"}}));
    }
 
    // Open a snapshot read cursor on db1.coll.
    let res = assert.commandWorked(db1.runCommand(
        {find: "coll", batchSize: 2, readConcern: {level: "snapshot"}, txnNumber: NumberLong(0)}));
 
    // Open a snapshot read cursor on db2.coll.
    res = assert.commandWorked(db2.runCommand(
        {find: "coll", batchSize: 2, readConcern: {level: "snapshot"}, txnNumber: NumberLong(1)}));
 
    // db2.coll is not locked, so this drop succeeds, when it should fail.
    db2.coll.drop();
    rst.stopSet();
}());

Sprint: Storage NYC 2018-03-26
Participants:

 Description   

This is what happens in the repro. First we open a snapshot cursor on db1.coll. The next operation has a higher txnNumber, so we set _isSnapshotTxn to false. Then we unstash resources from the previous operation onto our OperationContext, since we have not cleared stashed resources. Then at the end of the operation, since _isSnapshotTxn is false, we do not stash resources. This allows us to drop db2.coll.

I did not demonstrate this in the repro, but the second read is also holding the locks from the first read while it is running.



 Comments   
Comment by Tess Avitabile (Inactive) [ 08/Mar/18 ]

This may end up being a duplicate of SERVER-33432.

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