From 1e7fd17ee33d8c7c8e6c49e590c722ff71c7079e Mon Sep 17 00:00:00 2001 From: Dianna Hohensee Date: Mon, 22 Feb 2016 16:39:35 -0500 Subject: SERVER-22794 fixing network error in continuous step down thread due to unaccounted for primary step down closing connections --- .../sharding_continuous_config_stepdown.js | 25 +++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'jstests') diff --git a/jstests/libs/override_methods/sharding_continuous_config_stepdown.js b/jstests/libs/override_methods/sharding_continuous_config_stepdown.js index e50a6cd971d..56163dc892d 100644 --- a/jstests/libs/override_methods/sharding_continuous_config_stepdown.js +++ b/jstests/libs/override_methods/sharding_continuous_config_stepdown.js @@ -41,8 +41,31 @@ ReplSetTest = function ReplSetTestWithContinuousPrimaryStepdown() { print('*** Continuous stepdown thread running with seed node ' + seedNode); + // The config primary may unexpectedly step down during startup if under heavy load and + // too slowly processing heartbeats. When it steps down, it closes all of its connections. + // This can happen during the call to new ReplSetTest, so in order to account for this and + // make the tests stable, retry discovery of the replica set's configuration once + // (SERVER-22794). + var replSet; + var networkErrorRetries = 1; + while (networkErrorRetries >= 0) { + try { + replSet = new ReplSetTest(seedNode); + break; + } catch (e) { + if ( ((networkErrorRetries--) > 0) && + (e.toString().indexOf("network error") > -1) ) { + print("Error: " + e.toString() + "\nStacktrace: " + e.stack); + print("Stepdown thread's config server connection was closed, retrying."); + } else { + print('*** Continuous stepdown thread failed to connect to the ' + + 'config server: ' + tojson(e)); + return { ok: 0, error: e.toString(), stack: e.stack }; + } + } + } + try { - var replSet = new ReplSetTest(seedNode); var primary = replSet.getPrimary(); while (stopCounter.getCount() > 0) { -- cgit v1.2.1