summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlake Oler <blake.oler@mongodb.com>2018-04-20 16:19:09 -0400
committerBlake Oler <blake.oler@mongodb.com>2018-04-23 16:20:47 -0400
commit75ed77988ea3a9151caf602e39109b3c9533adb4 (patch)
treea9d6facce5d8bcb863da9b40c1a2a107546e4cae
parent1d4dbff63e25c104760f730eccb01b85726e376a (diff)
downloadmongo-75ed77988ea3a9151caf602e39109b3c9533adb4.tar.gz
SERVER-34599 Check status in sharding catalog client's applyChunkOpsDeprecated()
-rw-r--r--src/mongo/s/catalog/sharding_catalog_client_impl.cpp34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/mongo/s/catalog/sharding_catalog_client_impl.cpp b/src/mongo/s/catalog/sharding_catalog_client_impl.cpp
index 3bdb9b93dba..8987bc20c41 100644
--- a/src/mongo/s/catalog/sharding_catalog_client_impl.cpp
+++ b/src/mongo/s/catalog/sharding_catalog_client_impl.cpp
@@ -788,27 +788,31 @@ Status ShardingCatalogClientImpl::applyChunkOpsDeprecated(OperationContext* opCt
BSONObjBuilder query;
lastChunkVersion.addToBSON(query, ChunkType::lastmod());
query.append(ChunkType::ns(), nss.ns());
- auto swChunks = getChunks(opCtx, query.obj(), BSONObj(), 1, nullptr, readConcern);
- const auto& newestChunk = swChunks.getValue();
-
- if (!swChunks.isOK()) {
- errMsg = str::stream() << "getChunks function failed, unable to validate chunk "
- << "operation metadata: " << swChunks.getStatus().toString()
- << ". applyChunkOpsDeprecated failed to get confirmation "
- << "of commit. Unable to save chunk ops. Command: " << cmd
- << ". Result: " << response.getValue().response;
- } else if (!newestChunk.empty()) {
- invariant(newestChunk.size() == 1);
- return Status::OK();
- } else {
+ auto chunkWithStatus = getChunks(opCtx, query.obj(), BSONObj(), 1, nullptr, readConcern);
+
+ if (!chunkWithStatus.isOK()) {
+ errMsg = str::stream()
+ << "getChunks function failed, unable to validate chunk "
+ << "operation metadata: " << chunkWithStatus.getStatus().toString()
+ << ". applyChunkOpsDeprecated failed to get confirmation "
+ << "of commit. Unable to save chunk ops. Command: " << cmd
+ << ". Result: " << response.getValue().response;
+ return status.withContext(errMsg);
+ };
+
+ const auto& newestChunk = chunkWithStatus.getValue();
+
+ if (newestChunk.empty()) {
errMsg = str::stream() << "chunk operation commit failed: version "
<< lastChunkVersion.toString()
<< " doesn't exist in namespace: " << nss.ns()
<< ". Unable to save chunk ops. Command: " << cmd
<< ". Result: " << response.getValue().response;
- }
+ return status.withContext(errMsg);
+ };
- return status.withContext(errMsg);
+ invariant(newestChunk.size() == 1);
+ return Status::OK();
}
return Status::OK();