From 24ce8e9b42bc34d111999f516b8c5b2abedb8892 Mon Sep 17 00:00:00 2001 From: Jack Mulrow Date: Thu, 3 Sep 2020 19:14:46 +0000 Subject: SERVER-50635 Retry index consistency check at ShardingTest shutdown on ShardNotFound errors --- .../check_indexes_consistent_across_cluster.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/jstests/libs/override_methods/check_indexes_consistent_across_cluster.js b/jstests/libs/override_methods/check_indexes_consistent_across_cluster.js index 61f7603f4c5..d30673b0c5a 100644 --- a/jstests/libs/override_methods/check_indexes_consistent_across_cluster.js +++ b/jstests/libs/override_methods/check_indexes_consistent_across_cluster.js @@ -39,7 +39,21 @@ ShardingTest.prototype.checkIndexesConsistentAcrossCluster = function() { */ function makeGetIndexDocsFunc(ns) { return () => { - return ShardedIndexUtil.getPerShardIndexes(mongos.getCollection(ns)); + while (true) { + try { + return ShardedIndexUtil.getPerShardIndexes(mongos.getCollection(ns)); + } catch (e) { + // Getting the indexes can fail with ShardNotFound if the router's ShardRegistry + // reloads after choosing which shards to target and a chosen shard is no longer + // in the cluster. This error should be transient, so it can be retried on. + if (e.code === ErrorCodes.ShardNotFound) { + print("Retrying $indexStats aggregation on ShardNotFound error: " + + tojson(e)); + continue; + } + throw e; + } + } }; } -- cgit v1.2.1