Skip to content

Commit 1e7fd17

Browse files
author
Dianna Hohensee
committed
SERVER-22794 fixing network error in continuous step down thread due to unaccounted for primary step down closing connections
1 parent 6eb09b5 commit 1e7fd17

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

jstests/libs/override_methods/sharding_continuous_config_stepdown.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,31 @@ ReplSetTest = function ReplSetTestWithContinuousPrimaryStepdown() {
4141

4242
print('*** Continuous stepdown thread running with seed node ' + seedNode);
4343

44+
// The config primary may unexpectedly step down during startup if under heavy load and
45+
// too slowly processing heartbeats. When it steps down, it closes all of its connections.
46+
// This can happen during the call to new ReplSetTest, so in order to account for this and
47+
// make the tests stable, retry discovery of the replica set's configuration once
48+
// (SERVER-22794).
49+
var replSet;
50+
var networkErrorRetries = 1;
51+
while (networkErrorRetries >= 0) {
52+
try {
53+
replSet = new ReplSetTest(seedNode);
54+
break;
55+
} catch (e) {
56+
if ( ((networkErrorRetries--) > 0) &&
57+
(e.toString().indexOf("network error") > -1) ) {
58+
print("Error: " + e.toString() + "\nStacktrace: " + e.stack);
59+
print("Stepdown thread's config server connection was closed, retrying.");
60+
} else {
61+
print('*** Continuous stepdown thread failed to connect to the ' +
62+
'config server: ' + tojson(e));
63+
return { ok: 0, error: e.toString(), stack: e.stack };
64+
}
65+
}
66+
}
67+
4468
try {
45-
var replSet = new ReplSetTest(seedNode);
4669
var primary = replSet.getPrimary();
4770

4871
while (stopCounter.getCount() > 0) {

0 commit comments

Comments
 (0)