diff options
author | Gregory Noma <gregory.noma@gmail.com> | 2020-04-14 16:35:27 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-04-14 20:58:40 +0000 |
commit | be3eeca3c9802293b4a18cfae2d28c6cd41dfa29 (patch) | |
tree | 7bae1bdf12cea34a7fbfc539c12113e7618d7cdc /src/mongo | |
parent | 091c38c8b87d3276dd8b13e7425693493ea29cea (diff) | |
download | mongo-be3eeca3c9802293b4a18cfae2d28c6cd41dfa29.tar.gz |
SERVER-47410 Preserve error codes in ShardServerCatalogCacheLoader
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/s/shard_server_catalog_cache_loader.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/mongo/db/s/shard_server_catalog_cache_loader.cpp b/src/mongo/db/s/shard_server_catalog_cache_loader.cpp index 428b98a5aeb..93fed41830b 100644 --- a/src/mongo/db/s/shard_server_catalog_cache_loader.cpp +++ b/src/mongo/db/s/shard_server_catalog_cache_loader.cpp @@ -191,11 +191,11 @@ ChunkVersion getPersistedMaxChunkVersion(OperationContext* opCtx, const Namespac // There is no persisted metadata. return ChunkVersion::UNSHARDED(); } - uassert(ErrorCodes::OperationFailed, - str::stream() << "Failed to read persisted collections entry for collection '" - << nss.ns() << "' due to '" << statusWithCollection.getStatus().toString() - << "'.", - statusWithCollection.isOK()); + + uassertStatusOKWithContext(statusWithCollection, + str::stream() + << "Failed to read persisted collections entry for collection '" + << nss.ns() << "'."); auto statusWithChunk = shardmetadatautil::readShardChunks(opCtx, @@ -204,11 +204,10 @@ ChunkVersion getPersistedMaxChunkVersion(OperationContext* opCtx, const Namespac BSON(ChunkType::lastmod() << -1), 1LL, statusWithCollection.getValue().getEpoch()); - uassert(ErrorCodes::OperationFailed, - str::stream() << "Failed to read highest version persisted chunk for collection '" - << nss.ns() << "' due to '" << statusWithChunk.getStatus().toString() - << "'.", - statusWithChunk.isOK()); + uassertStatusOKWithContext( + statusWithChunk, + str::stream() << "Failed to read highest version persisted chunk for collection '" + << nss.ns() << "'."); return statusWithChunk.getValue().empty() ? ChunkVersion::UNSHARDED() : statusWithChunk.getValue().front().getVersion(); @@ -293,9 +292,7 @@ StatusWith<CollectionAndChangedChunks> getIncompletePersistedMetadataSinceVersio if (status == ErrorCodes::NamespaceNotFound) { return CollectionAndChangedChunks(); } - return Status(ErrorCodes::OperationFailed, - str::stream() - << "Failed to load local metadata due to '" << status.toString() << "'."); + return status.withContext(str::stream() << "Failed to load local metadata."); } } |