[SERVER-31604] Shell's connection object with retryable writes enabled does not pass `txnNumber` for removes Created: 17/Oct/17  Updated: 27/Oct/23  Resolved: 17/Oct/17

Status: Closed
Project: Core Server
Component/s: Testing Infrastructure
Affects Version/s: 3.6.0-rc0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Kaloian Manassiev Assignee: Max Hirschhorn
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Steps To Reproduce:

Create a new client, run insert and remove and inspect the contents of the oplog:

var dbWithSession = new Mongo('localhost:20000').startSession({retryWrites:true}).getDatabase('TestDB');

For inserts:

dbWithSession.insert({_id: 1});

The oplog contains lsid/txnNumber information:

{
        "ts" : Timestamp(1508263733, 1),
        "t" : NumberLong(1),
        "h" : NumberLong("5813089571967450467"),
        "v" : 2,
        "op" : "i",
        "ns" : "TestDB.TestColl",
        "ui" : UUID("e551162e-21a0-4c90-82e5-9e6ea239ef1f"),
        "wall" : ISODate("2017-10-17T18:08:53.938Z"),
        "lsid" : {
                "id" : UUID("62f09f8b-5f90-4a5c-9c39-708923793815"),
                "uid" : BinData(0,"47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=")
        },
        "txnNumber" : NumberLong(0),
        "stmtId" : 0,
        "prevOpTime" : {
                "ts" : Timestamp(0, 0),
                "t" : NumberLong(-1)
        },
        "o" : {
                "_id" : 1
        }
}

For removes:

dbWithSession.TestColl.remove({_id: 0});

It doesn't:

{
        "ts" : Timestamp(1508263783, 1),
        "t" : NumberLong(1),
        "h" : NumberLong("6684227120267171736"),
        "v" : 2,
        "op" : "d",
        "ns" : "TestDB.TestColl",
        "ui" : UUID("e551162e-21a0-4c90-82e5-9e6ea239ef1f"),
        "wall" : ISODate("2017-10-17T18:09:43.947Z"),
        "o" : {
                "_id" : 1
        }
}

Participants:

 Description   

The remove operation on a shell connection object with sessions enabled does not pass txnNumber. See the steps to reproduce for more information.



 Comments   
Comment by Max Hirschhorn [ 17/Oct/17 ]

kaloian.manassiev, DBCollection.prototype.remove() defaults to do a multi-remove if you don't specify {justOne: true} explicitly. The following JavaScript test passes for me locally.

shell_assign_transaction_number.js

(function() {
    "use strict";
 
    const rst = new ReplSetTest({nodes: 1, useBridge: true, bridgeOptions: {verbose: ""}});
    rst.startSet();
    rst.initiate();
 
    const db = rst.getPrimary().startSession({retryWrites: true}).getDatabase("test");
    assert.writeOK(db.mycoll.insert({_id: 1}));
    assert.writeOK(db.mycoll.remove({_id: 1}, {justOne: true}));
 
    db.getSiblingDB("local").oplog.rs.find({"o._id": 1}).forEach(function(op) {
        assert(op.hasOwnProperty("txnNumber"),
               "operation " + tojsononeline(op) + " doesn't have a txnNumber");
    });
 
    rst.stopSet();
})();

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