summaryrefslogtreecommitdiff
path: root/jstests/concurrency/fsm_workloads/yield_fetch.js
blob: b3f47a5fe5d8fd357a96d30546fa7fbfdc58fa2e (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
'use strict';

/*
 * yield_fetch.js (extends yield_rooted_or.js)
 *
 * Intersperse queries which use the FETCH stage with updates and deletes of documents they may
 * match.
 */
load('jstests/concurrency/fsm_libs/extend_workload.js');       // for extendWorkload
load('jstests/concurrency/fsm_workloads/yield_rooted_or.js');  // for $config

var $config = extendWorkload(
    $config,
    function($config, $super) {

        /*
         * Issue a query that will use the FETCH stage.
         */
        $config.states.query = function fetch(db, collName) {
            var nMatches = 100;

            var cursor = db[collName].find({c: {$lt: nMatches}}).batchSize(this.batchSize);

            var verifier = function fetchVerifier(doc, prevDoc) {
                return doc.c < nMatches;
            };

            this.advanceCursor(cursor, verifier);
        };

        return $config;
    });