diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2017-06-12 15:38:37 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2017-06-13 13:57:24 -0400 |
commit | 133f0fd284abdf8a313d47b412f58e2cba60cc80 (patch) | |
tree | 5c9c75737641a43faf6f994337256e34418d7942 /src/mongo/s | |
parent | 70fbe624d5d96e0c205278fc57f886104ad545e5 (diff) | |
download | mongo-133f0fd284abdf8a313d47b412f58e2cba60cc80.tar.gz |
SERVER-29489 Use 'maxTimeMs' when calling listDatabases against shards
Diffstat (limited to 'src/mongo/s')
-rw-r--r-- | src/mongo/s/catalog/sharding_catalog_test.cpp | 2 | ||||
-rw-r--r-- | src/mongo/s/shard_util.cpp | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/mongo/s/catalog/sharding_catalog_test.cpp b/src/mongo/s/catalog/sharding_catalog_test.cpp index 54ec129b13c..0e0085e8c30 100644 --- a/src/mongo/s/catalog/sharding_catalog_test.cpp +++ b/src/mongo/s/catalog/sharding_catalog_test.cpp @@ -1786,7 +1786,7 @@ TEST_F(ShardingCatalogClientTest, EnableShardingNoDBExists) { onCommand([](const RemoteCommandRequest& request) { ASSERT_EQ(HostAndPort("shard0:12"), request.target); ASSERT_EQ("admin", request.dbname); - ASSERT_BSONOBJ_EQ(BSON("listDatabases" << 1), request.cmdObj); + ASSERT_BSONOBJ_EQ(BSON("listDatabases" << 1 << "maxTimeMS" << 600000), request.cmdObj); ASSERT_BSONOBJ_EQ(ReadPreferenceSetting::secondaryPreferredMetadata(), rpc::TrackingMetadata::removeTrackingData(request.metadata)); diff --git a/src/mongo/s/shard_util.cpp b/src/mongo/s/shard_util.cpp index b440a6c6491..b66cfc82ce9 100644 --- a/src/mongo/s/shard_util.cpp +++ b/src/mongo/s/shard_util.cpp @@ -59,15 +59,22 @@ StatusWith<long long> retrieveTotalShardSize(OperationContext* opCtx, const Shar return shardStatus.getStatus(); } + // Since 'listDatabases' is potentially slow in the presence of large number of collections, use + // a higher maxTimeMS to prevent it from prematurely timing out + const Minutes maxTimeMSOverride{10}; + auto listDatabasesStatus = shardStatus.getValue()->runCommandWithFixedRetryAttempts( opCtx, ReadPreferenceSetting{ReadPreference::PrimaryPreferred}, "admin", BSON("listDatabases" << 1), + maxTimeMSOverride, Shard::RetryPolicy::kIdempotent); + if (!listDatabasesStatus.isOK()) { return std::move(listDatabasesStatus.getStatus()); } + if (!listDatabasesStatus.getValue().commandStatus.isOK()) { return std::move(listDatabasesStatus.getValue().commandStatus); } |