summaryrefslogtreecommitdiff
path: root/jstests/concurrency/fsm_workloads/remove_and_bulk_insert.js
blob: 74139f07117fa6799acb898dcc9f37571886c595 (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
39
40
41
42
'use strict';

/**
 * remove_and_bulk_insert.js
 *
 * Each thread alternates between inserting 1000 documents and deleting the entire contents of the
 * collection.
 *
 * This workload was designed to reproduce SERVER-20512, where a record in an evicted page was
 * accessed after a WriteConflictException occurred in Collection::deleteDocument().
 */
var $config = (function() {

    var states = {
        insert: function insert(db, collName) {
            var bulk = db[collName].initializeUnorderedBulkOp();
            for (var i = 0; i < 1000; ++i) {
                bulk.insert({});
            }
            assert.writeOK(bulk.execute());
        },

        remove: function remove(db, collName) {
            var res = db[collName].remove({});
            assertAlways.lte(0, res.nRemoved, tojson(res));
        }
    };

    var transitions = {
        insert: { insert: 0.5, remove: 0.5 },
        remove: { insert: 0.5, remove: 0.5 }
    };

    return {
        threadCount: 5,
        iterations: 50,
        startState: 'insert',
        states: states,
        transitions: transitions
    };

})();