diff options
author | Dianna Hohensee <dianna.hohensee@10gen.com> | 2017-07-10 14:21:57 -0400 |
---|---|---|
committer | Dianna Hohensee <dianna.hohensee@10gen.com> | 2017-07-10 19:38:01 -0400 |
commit | 3b1554c77ce9c80b30044654ff2cab3aff7070d4 (patch) | |
tree | efbcf847f86b37349d51dfe91414e7312ae02172 /src/mongo/s | |
parent | a13467bddf585a6265e09319f1f769fc0e60beb0 (diff) | |
download | mongo-3b1554c77ce9c80b30044654ff2cab3aff7070d4.tar.gz |
SERVER-29745 after a successful migration, ensure the metadata update is persisted before range deletion is schedule
Diffstat (limited to 'src/mongo/s')
-rw-r--r-- | src/mongo/s/catalog_cache.cpp | 6 | ||||
-rw-r--r-- | src/mongo/s/catalog_cache.h | 18 | ||||
-rw-r--r-- | src/mongo/s/catalog_cache_loader.h | 7 | ||||
-rw-r--r-- | src/mongo/s/config_server_catalog_cache_loader.cpp | 6 | ||||
-rw-r--r-- | src/mongo/s/config_server_catalog_cache_loader.h | 3 |
5 files changed, 40 insertions, 0 deletions
diff --git a/src/mongo/s/catalog_cache.cpp b/src/mongo/s/catalog_cache.cpp index 255ed96df69..9677b8bc58f 100644 --- a/src/mongo/s/catalog_cache.cpp +++ b/src/mongo/s/catalog_cache.cpp @@ -178,6 +178,12 @@ void CatalogCache::notifyOfCollectionVersionUpdate(OperationContext* opCtx, _cacheLoader->notifyOfCollectionVersionUpdate(opCtx, nss, version); } +Status CatalogCache::waitForCollectionVersion(OperationContext* opCtx, + const NamespaceString& nss, + const ChunkVersion& version) { + return _cacheLoader->waitForCollectionVersion(opCtx, nss, version); +} + StatusWith<CachedDatabaseInfo> CatalogCache::getDatabase(OperationContext* opCtx, StringData dbName) { try { diff --git a/src/mongo/s/catalog_cache.h b/src/mongo/s/catalog_cache.h index a978642c825..9b261de3a43 100644 --- a/src/mongo/s/catalog_cache.h +++ b/src/mongo/s/catalog_cache.h @@ -98,6 +98,24 @@ public: const ChunkVersion& version); /** + * Waits for the persisted collection version to be gte to 'version', or an epoch change. Only + * call this function if you KNOW that a version gte WILL eventually be persisted. + * + * This function cannot wait for a version if nothing is persisted because a collection can + * become unsharded after we start waiting and 'version' will then never be reached. If 'nss' + * has no persisted metadata, even if it will shortly, a NamespaceNotFound error will be + * returned. + * + * A lock must not be held when calling this because it would prevent using the latest snapshot + * and actually seeing the change after it arrives. + * This function can throw a DBException if the opCtx is interrupted. + * This can only be called on a shard! + */ + Status waitForCollectionVersion(OperationContext* opCtx, + const NamespaceString& nss, + const ChunkVersion& version); + + /** * Retrieves the cached metadata for the specified database. The returned value is still owned * by the cache and should not be kept elsewhere. I.e., it should only be used as a local * variable. The reason for this is so that if the cache gets invalidated, the caller does not diff --git a/src/mongo/s/catalog_cache_loader.h b/src/mongo/s/catalog_cache_loader.h index 7405d225d5b..3257cb8fbc5 100644 --- a/src/mongo/s/catalog_cache_loader.h +++ b/src/mongo/s/catalog_cache_loader.h @@ -96,6 +96,13 @@ public: const ChunkVersion& version) = 0; /** + * Waits for the persisted collection version to be GTE to 'version', or an epoch change. + */ + virtual Status waitForCollectionVersion(OperationContext* opCtx, + const NamespaceString& nss, + const ChunkVersion& version) = 0; + + /** * Non-blocking call, which requests the chunks changed since the specified version to be * fetched from the persistent metadata store and invokes the callback function with the result. * The callback function must never throw - it is a fatal error to do so. diff --git a/src/mongo/s/config_server_catalog_cache_loader.cpp b/src/mongo/s/config_server_catalog_cache_loader.cpp index 79cea4d8211..e0ca6968b91 100644 --- a/src/mongo/s/config_server_catalog_cache_loader.cpp +++ b/src/mongo/s/config_server_catalog_cache_loader.cpp @@ -159,6 +159,12 @@ void ConfigServerCatalogCacheLoader::notifyOfCollectionVersionUpdate(OperationCo MONGO_UNREACHABLE; } +Status ConfigServerCatalogCacheLoader::waitForCollectionVersion(OperationContext* opCtx, + const NamespaceString& nss, + const ChunkVersion& version) { + MONGO_UNREACHABLE; +} + std::shared_ptr<Notification<void>> ConfigServerCatalogCacheLoader::getChunksSince( const NamespaceString& nss, ChunkVersion version, diff --git a/src/mongo/s/config_server_catalog_cache_loader.h b/src/mongo/s/config_server_catalog_cache_loader.h index 9f7512f30bb..1a2451628da 100644 --- a/src/mongo/s/config_server_catalog_cache_loader.h +++ b/src/mongo/s/config_server_catalog_cache_loader.h @@ -47,6 +47,9 @@ public: void notifyOfCollectionVersionUpdate(OperationContext* opCtx, const NamespaceString& nss, const ChunkVersion& version) override; + Status waitForCollectionVersion(OperationContext* opCtx, + const NamespaceString& nss, + const ChunkVersion& version) override; std::shared_ptr<Notification<void>> getChunksSince( const NamespaceString& nss, |