Files
mongo/jstests/replsets/write_concern_update_where.js
Rui Liu 8bc38915fc SERVER-87126 Skip waiting write concern for direct client (#24602)
GitOrigin-RevId: 9d7f8511d17d2f2e1c43acebcde6bb2309b5d8d7
2024-07-21 21:06:56 +00:00

25 lines
782 B
JavaScript

/**
* Tests update with $where does not wait for write concern (which would trigger assertion while
* holding global lock) when it iterates system.js collection using DBDirectClient.
*/
const rst = new ReplSetTest({name: jsTestName(), nodes: 2});
rst.startSet();
rst.initiate();
const db = rst.getPrimary().getDB(jsTestName());
for (var i = 0; i < 3000; i++) {
db.system.js.insertOne({
_id: "test" + i,
value: function(x) {
return x;
}
});
}
assert.commandWorked(db.coll.insertOne({x: 1}));
assert.commandWorked(db.coll.updateMany({$where: "function() { return test0(this.x) != 0; }"},
{$set: {x: 2}},
{writeConcern: {w: "majority"}}));
rst.stopSet();