diff options
author | Martin Neupauer <martin.neupauer@10gen.com> | 2018-03-26 19:30:26 -0400 |
---|---|---|
committer | Martin Neupauer <martin.neupauer@mongodb.com> | 2018-04-05 12:52:02 -0400 |
commit | a6d486b8a6e0c81771bd771cc0237236791d635d (patch) | |
tree | 61b49fae8cf316c033b2ac707202e50b281cc72a /src/mongo/db/s/shard_filtering_metadata_refresh.cpp | |
parent | 6fbc1bbfcd5ffcfb451c300a6ef523f19d5edb55 (diff) | |
download | mongo-a6d486b8a6e0c81771bd771cc0237236791d635d.tar.gz |
SERVER-33523 Add timestamp support to CollectionMetadata
Diffstat (limited to 'src/mongo/db/s/shard_filtering_metadata_refresh.cpp')
-rw-r--r-- | src/mongo/db/s/shard_filtering_metadata_refresh.cpp | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/mongo/db/s/shard_filtering_metadata_refresh.cpp b/src/mongo/db/s/shard_filtering_metadata_refresh.cpp index eed8ca38df0..e641d43578e 100644 --- a/src/mongo/db/s/shard_filtering_metadata_refresh.cpp +++ b/src/mongo/db/s/shard_filtering_metadata_refresh.cpp @@ -72,7 +72,7 @@ Status onShardVersionMismatch(OperationContext* opCtx, const auto currentShardVersion = [&] { AutoGetCollection autoColl(opCtx, nss, MODE_IS); - const auto currentMetadata = CollectionShardingState::get(opCtx, nss)->getMetadata(); + const auto currentMetadata = CollectionShardingState::get(opCtx, nss)->getMetadata(opCtx); if (currentMetadata) { return currentMetadata->getShardVersion(); } @@ -122,15 +122,14 @@ ChunkVersion forceShardFilteringMetadataRefresh(OperationContext* opCtx, { AutoGetCollection autoColl(opCtx, nss, MODE_IS); - auto css = CollectionShardingState::get(opCtx, nss); + auto metadata = CollectionShardingState::get(opCtx, nss)->getMetadata(opCtx); // We already have newer version - if (css->getMetadata() && - css->getMetadata()->getCollVersion().epoch() == cm->getVersion().epoch() && - css->getMetadata()->getCollVersion() >= cm->getVersion()) { + if (metadata && metadata->getCollVersion().epoch() == cm->getVersion().epoch() && + metadata->getCollVersion() >= cm->getVersion()) { LOG(1) << "Skipping refresh of metadata for " << nss << " " - << css->getMetadata()->getCollVersion() << " with an older " << cm->getVersion(); - return css->getMetadata()->getShardVersion(); + << metadata->getCollVersion() << " with an older " << cm->getVersion(); + return metadata->getShardVersion(); } } @@ -138,14 +137,14 @@ ChunkVersion forceShardFilteringMetadataRefresh(OperationContext* opCtx, AutoGetCollection autoColl(opCtx, nss, MODE_IX, MODE_X); auto css = CollectionShardingState::get(opCtx, nss); + auto metadata = css->getMetadata(opCtx); // We already have newer version - if (css->getMetadata() && - css->getMetadata()->getCollVersion().epoch() == cm->getVersion().epoch() && - css->getMetadata()->getCollVersion() >= cm->getVersion()) { - LOG(1) << "Skipping refresh of metadata for " << nss << " " - << css->getMetadata()->getCollVersion() << " with an older " << cm->getVersion(); - return css->getMetadata()->getShardVersion(); + if (metadata && metadata->getCollVersion().epoch() == cm->getVersion().epoch() && + metadata->getCollVersion() >= cm->getVersion()) { + LOG(1) << "Skipping refresh of metadata for " << nss << " " << metadata->getCollVersion() + << " with an older " << cm->getVersion(); + return metadata->getShardVersion(); } std::unique_ptr<CollectionMetadata> newCollectionMetadata = @@ -153,7 +152,7 @@ ChunkVersion forceShardFilteringMetadataRefresh(OperationContext* opCtx, css->refreshMetadata(opCtx, std::move(newCollectionMetadata)); - return css->getMetadata()->getShardVersion(); + return css->getMetadata(opCtx)->getShardVersion(); } void onDbVersionMismatch(OperationContext* opCtx, |