summaryrefslogtreecommitdiff
path: root/jstests/core/remove9.js
blob: 888625764ecfe774969949e38cc561f843229eeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// @tags: [
//   requires_getmore,
//   requires_non_retryable_writes,
//   uses_multiple_connections,
// ]

// SERVER-2009 Count odd numbered entries while updating and deleting even numbered entries.

(function() {
"use strict";

const t = db.jstests_remove9;
t.drop();
t.ensureIndex({i: 1});

const bulk = t.initializeUnorderedBulkOp();
for (let i = 0; i < 1000; ++i) {
    bulk.insert({i: i});
}
assert.writeOK(bulk.execute());

const s = startParallelShell(function() {
    const t = db.jstests_remove9;
    Random.setRandomSeed();
    for (let j = 0; j < 5000; ++j) {
        const i = Random.randInt(499) * 2;
        t.update({i: i}, {$set: {i: 2000}});
        t.remove({i: 2000});
        t.save({i: i});
    }
});

for (let i = 0; i < 1000; ++i) {
    assert.eq(500, t.find({i: {$gte: 0, $mod: [2, 1]}}).hint({i: 1}).itcount());
}

s();
})();