Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-21523

Injected "threadCount" property is defined before scaling down by ThreadManager

    • Fully Compatible
    • ALL
    • Hide

      Apply the following patch and run python buildscripts/resmoke.py --executor concurrency jstests/concurrency/fsm_all.js to produce output that shows although 105 threads were requested and 100 were used, the workload's setup function sees 105 threads being used.

      Unable to find source-code formatter for language: diff. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      diff --git a/jstests/concurrency/fsm_all.js b/jstests/concurrency/fsm_all.js
      index c174342..f1e5f09 100644
      --- a/jstests/concurrency/fsm_all.js
      +++ b/jstests/concurrency/fsm_all.js
      @@ -7,6 +7,6 @@ var dir = 'jstests/concurrency/fsm_workloads';
       var blacklist = [
       ].map(function(file) { return dir + '/' + file; });
       
      -runWorkloadsSerially(ls(dir).filter(function(file) {
      -    return !Array.contains(blacklist, file);
      -}));
      +runWorkloadsSerially(['jstests/concurrency/fsm_workloads/threadcount.js'], {}, {
      +    threadMultiplier: 105
      +});
      diff --git a/jstests/concurrency/fsm_libs/runner.js b/jstests/concurrency/fsm_libs/runner.js
      index cfe6136..ceb0f85 100644
      --- a/jstests/concurrency/fsm_libs/runner.js
      +++ b/jstests/concurrency/fsm_libs/runner.js
      @@ -561,7 +561,9 @@ var runner = (function() {
                   dropAllDatabases(cluster.getDB('test'), dbBlacklist);
               }
       
      -        var maxAllowedThreads = 100 * executionOptions.threadMultiplier;
      +        // Skip multiplying maxAllowedThreads by the threadMultiplier to trigger the ThreadManager
      +        // to scale the number of threads used down.
      +        var maxAllowedThreads = 100;
               Random.setRandomSeed(clusterOptions.seed);
               var bgCleanup = [];
               var errors = [];
      diff --git a/jstests/concurrency/fsm_workloads/threadcount.js b/jstests/concurrency/fsm_workloads/threadcount.js
      new file mode 100644
      index 0000000..e83f962
      --- /dev/null
      +++ b/jstests/concurrency/fsm_workloads/threadcount.js
      @@ -0,0 +1,21 @@
      +'use strict';
      +
      +var $config = (function() {
      +
      +    var states = { noop: function noop(db, collName) {} };
      +    var transitions = { noop: { noop: 1 } };
      +
      +    function setup(db, collName, cluster) {
      +        jsTest.log(`setup() function sees threadCount=${this.threadCount}`);
      +    }
      +
      +    return {
      +        threadCount: 1,
      +        iterations: 10,
      +        startState: 'noop',
      +        states: states,
      +        transitions: transitions,
      +        setup: setup
      +    };
      +
      +})();
      
      Show
      Apply the following patch and run python buildscripts/resmoke.py --executor concurrency jstests/concurrency/fsm_all.js to produce output that shows although 105 threads were requested and 100 were used, the workload's setup function sees 105 threads being used. Unable to find source-code formatter for language: diff. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml diff --git a/jstests/concurrency/fsm_all.js b/jstests/concurrency/fsm_all.js index c174342..f1e5f09 100644 --- a/jstests/concurrency/fsm_all.js +++ b/jstests/concurrency/fsm_all.js @@ -7,6 +7,6 @@ var dir = 'jstests/concurrency/fsm_workloads' ; var blacklist = [ ].map(function(file) { return dir + '/' + file; }); -runWorkloadsSerially(ls(dir).filter(function(file) { - return !Array.contains(blacklist, file); -})); +runWorkloadsSerially([ 'jstests/concurrency/fsm_workloads/threadcount.js' ], {}, { + threadMultiplier: 105 +}); diff --git a/jstests/concurrency/fsm_libs/runner.js b/jstests/concurrency/fsm_libs/runner.js index cfe6136..ceb0f85 100644 --- a/jstests/concurrency/fsm_libs/runner.js +++ b/jstests/concurrency/fsm_libs/runner.js @@ -561,7 +561,9 @@ var runner = (function() { dropAllDatabases(cluster.getDB( 'test' ), dbBlacklist); } - var maxAllowedThreads = 100 * executionOptions.threadMultiplier; + // Skip multiplying maxAllowedThreads by the threadMultiplier to trigger the ThreadManager + // to scale the number of threads used down. + var maxAllowedThreads = 100; Random.setRandomSeed(clusterOptions.seed); var bgCleanup = []; var errors = []; diff --git a/jstests/concurrency/fsm_workloads/threadcount.js b/jstests/concurrency/fsm_workloads/threadcount.js new file mode 100644 index 0000000..e83f962 --- /dev/ null +++ b/jstests/concurrency/fsm_workloads/threadcount.js @@ -0,0 +1,21 @@ + 'use strict' ; + + var $config = (function() { + + var states = { noop: function noop(db, collName) {} }; + var transitions = { noop: { noop: 1 } }; + + function setup(db, collName, cluster) { + jsTest.log(`setup() function sees threadCount=${ this .threadCount}`); + } + + return { + threadCount: 1, + iterations: 10, + startState: 'noop' , + states: states, + transitions: transitions, + setup: setup + }; + +})();
    • QuInt C (11/23/15)

      In order for an FSM workload's setup(), teardown(), and state functions to know the actual number of copies of itself that are running, the following initialization order is necessary.

      1. Apply the threadMultiplier.
      2. Call ThreadManager.prototype.init() to compute the actual number of copies of a workload that will run. This number may be less than the requested one to avoid resource issues on the test hosts.
      3. Define the read-only "threadCount" property on the $config.data object.
      4. Invoke the workload's setup() function.

      Note that this issue doesn't affect any of the active fsm_all_xx.js tests that run in Evergreen because a single workload does not request to run with more than 100 threads.

      [js_test:fsm_all] 2015-11-18T01:32:40.227-0500 ----
      [js_test:fsm_all] 2015-11-18T01:32:40.227-0500 Workload(s) started: jstests/concurrency/fsm_workloads/threadcount.js
      [js_test:fsm_all] 2015-11-18T01:32:40.227-0500 ----
      [js_test:fsm_all] 2015-11-18T01:32:40.227-0500
      [js_test:fsm_all] 2015-11-18T01:32:40.227-0500
      [js_test:fsm_all] 2015-11-18T01:32:40.227-0500
      [js_test:fsm_all] 2015-11-18T01:32:40.227-0500
      [js_test:fsm_all] 2015-11-18T01:32:40.227-0500 ----
      [js_test:fsm_all] 2015-11-18T01:32:40.227-0500 setup() function sees threadCount=105
      [js_test:fsm_all] 2015-11-18T01:32:40.228-0500 ----
      [js_test:fsm_all] 2015-11-18T01:32:40.228-0500
      [js_test:fsm_all] 2015-11-18T01:32:40.228-0500
      [js_test:fsm_all] 2015-11-18T01:32:40.228-0500 Using 100 threads (requested 105)
      

            Assignee:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Reporter:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: