[SERVER-21523] Injected "threadCount" property is defined before scaling down by ThreadManager Created: 18/Nov/15  Updated: 25/Nov/15  Resolved: 19/Nov/15

Status: Closed
Project: Core Server
Component/s: Testing Infrastructure
Affects Version/s: 3.2.0-rc3
Fix Version/s: 3.2.0-rc4

Type: Bug Priority: Major - P3
Reporter: Max Hirschhorn Assignee: Max Hirschhorn
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-21499 Enable fsm_all_simultaneous.js (FSM p... Closed
Related
is related to SERVER-21310 Inject iterations and threadCount int... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

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.

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
+    };
+
+})();

Sprint: QuInt C (11/23/15)
Participants:

 Description   

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)



 Comments   
Comment by Githook User [ 19/Nov/15 ]

Author:

{u'username': u'visemet', u'name': u'Max Hirschhorn', u'email': u'max.hirschhorn@mongodb.com'}

Message: SERVER-21523 Inject "threadCount" property after threadMgr.init().
Branch: master
https://github.com/mongodb/mongo/commit/4d3741272a78c7880f0aa20b144e83c71ac2e4d8

Generated at Thu Feb 08 03:57:36 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.