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

Add configuration options to JavaScript stepdown thread

    • Fully Compatible
    • Sharding 2017-09-11

      The intention is for the majority of the logic of jstests/libs/override_methods/sharding_continuous_config_stepdown.js to be moved to a new continuous_stepdown.js file. The continuous_stepdown.js file should define a ContinuousStepdown global variable with a configure() function that takes the following options:

      configStepdown: boolean (default true)
      electionTimeoutMS: number (default 5 seconds)
      shardStepdown: boolean (default true)
      stepdownDurationSecs: number (default 10 seconds)
      stepdownIntervalMS: number (default 8 seconds)
      

      The ContinuousStepdown.configure(options) function should cause two new methods startContinuousFailover() and stopContinuousFailover() to be defined on ReplSetTest. The ReplSetTest#startContinuousFailover() function should run the "replSetReconfig" command to change the election timeout to options.electionTimeoutMS in order to support having a new primary get elected before the options.stepdownIntervalMS period would cause one to step down again. The ReplSetTest#startContinuousFailover() function should then start the stepdown thread.

      Note: It would likely be cleaner to do a bit of refactoring to the sharding_continuous_config_stepdown.js override and have an actual StepdownThread object (with its own start() and stop() methods) that manages the ScopedThread instance rather than doing it through ReplSetTest#startContinuousFailover() and ReplSetTest#stopContinuousFailover() directly.

      The stepdown thread should loop continuously until signaled to stop via a CountDownLatch instance. During each iteration of the loop, the stepdown thread should run the {replSetStepDown: options.stepdownDurationSecs, force: true} command and then call sleep(options.stepdownIntervalMS).

      Unlike the existing sharding_continuous_config_stepdown.js override, the ContinuousStepdown.configure(options) function should also cause two new methods startContinuousFailover() and stopContinuousFailover() to be defined on ShardingTest. The ShardingTest#startContinuousFailover() function should call ReplSetTest#startContinuousFailover() for the configRS property of ShardingTest when options.configStepdown is true, and should call ReplSetTest#startContinuousFailover() for each replica-set shard among the _rs property of ShardingTest when options.shardStepdown is true.

      The existing contents of sharding_continuous_config_stepdown.js are equivalent to

      (function() {
          "use strict";
      
          load("jstests/libs/override_methods/continuous_stepdown.js");
      
          ContinuousStepdown.configure({
              configStepdown: true,
              electionTimeoutMS: 5 * 1000,
              shardStepdown: false,
              stepdownDurationSecs: 10,
              stepdownIntervalMS: 8 * 1000,
          });
      
          const originalShardingTest = ShardingTest;
          ShardingTest = function() {
              originalShardingTest.apply(this, arguments);
      
              // Automatically start the continuous stepdown thread on the config server replica set.
              this.startContinuousFailover();
          };
      })();
      

      and should be replaced with something along the aforementioned lines to preserve the behavior of the sharding_continuous_config_stepdown.yml test suite.

            Assignee:
            jack.mulrow@mongodb.com Jack Mulrow
            Reporter:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: