diff options
author | Jordi Serra Torrens <jordi.serra-torrens@mongodb.com> | 2020-12-09 18:06:25 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-12-10 14:01:44 +0000 |
commit | ba633521a7c2815527be955b11a772395f153cd3 (patch) | |
tree | 76428c2186d1a11b4928137698ca72fe48af2376 /src/mongo/db/s/config/sharding_catalog_manager.h | |
parent | e36da1b27ef763f4d7367ddf0f2f97259c0deac3 (diff) | |
download | mongo-ba633521a7c2815527be955b11a772395f153cd3.tar.gz |
SERVER-52767: Handle collectionUUID in config.chunks on upgrade/downgrade
Diffstat (limited to 'src/mongo/db/s/config/sharding_catalog_manager.h')
-rw-r--r-- | src/mongo/db/s/config/sharding_catalog_manager.h | 108 |
1 files changed, 85 insertions, 23 deletions
diff --git a/src/mongo/db/s/config/sharding_catalog_manager.h b/src/mongo/db/s/config/sharding_catalog_manager.h index 5369ba926d9..d68bd3a4dad 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager.h +++ b/src/mongo/db/s/config/sharding_catalog_manager.h @@ -456,36 +456,20 @@ public: void removePre49LegacyMetadata(OperationContext* opCtx); /** - * Creates a 'version.timestamp' for each one of the entries in the config server's - * config.databases where it didn't already exist before. - * - * It shall be called when upgrading to 4.9 - */ - void createDBTimestampsFor49(OperationContext* opCtx); - - /** - * Downgrades the config.databases entries to prior 4.9 version. More specifically, it removes - * the 'version.timestamp' field from all the documents in config.databases. + * Patches-up persistent metadata for 4.9. * - * It shall be called when downgrading from 4.9 to an earlier version. - */ - void downgradeConfigDatabasesEntriesToPre49(OperationContext* opCtx); - - /** - * Creates a 'timestamp' for each one of the entries in the config server's config.collections, - * where 'timestamp' does not already exist. - * - * It shall be called when upgrading to 4.9. + * It shall be called when upgrading to 4.9 or newer versions. + * TODO SERVER-53283: Remove once 5.0 has been released. */ - void createCollectionTimestampsFor49(OperationContext* opCtx); + void upgradeMetadataFor49(OperationContext* opCtx); /** - * Downgrades the config.collections entries to prior 4.9 version. More specifically, it removes - * the 'timestamp' field from all the documents in config.collections. + * Patches-up persistent metadata for downgrade from 4.9. * * It shall be called when downgrading from 4.9 to an earlier version. + * TODO SERVER-53283: Remove once 5.0 has been released. */ - void downgradeConfigCollectionEntriesToPre49(OperationContext* opCtx); + void downgradeMetadataToPre49(OperationContext* opCtx); // // For Diagnostics @@ -603,6 +587,84 @@ private: const std::string& shardName, const std::string& zoneName); + /** + * Creates a 'version.timestamp' for each one of the entries in the config server's + * config.databases where it didn't already exist before. + * + * TODO SERVER-53283: Remove once 5.0 has been released. + */ + void _createDBTimestampsFor49(OperationContext* opCtx); + + /** + * Downgrades the config.databases entries to prior 4.9 version. More specifically, it removes + * the 'version.timestamp' field from all the documents in config.databases. + * + * TODO SERVER-53283: Remove once 5.0 has been released. + */ + void _downgradeConfigDatabasesEntriesToPre49(OperationContext* opCtx); + + /** + * For each one of the entries in config.collections where there is no 'timestamp', + * transactionally: + * - Patches-up the entries in config.chunks with a 'ns' matching that of the collection to add + * a 'collectionUuid' field matching the uuid of the collection. + * - Creates a 'timestamp' in its entry in config.collections. + * + * TODO SERVER-53283: Remove once 5.0 has been released. + */ + void _upgradeCollectionsAndChunksMetadataFor49(OperationContext* opCtx); + + /** + * For each one of the entries in config.collections where there is a 'timestamp', + * transactionally: + * - Patches-up the entries in config.chunks with a 'ns' matching that of the collection to + * unset the 'collectionUuid' field. + * - Unsets the 'timestamp' in its entry in config.collections. + * + * TODO SERVER-53283: Remove once 5.0 has been released. + */ + void _downgradeCollectionsAndChunksMetadataToPre49(OperationContext* opCtx); + + /** + * Creates a 'timestamp' field for the entry matching nss in config.collections, in a + * transaction. + * + * TODO SERVER-53283: Remove once 5.0 has been released. + */ + void _createCollectionTimestampFor49InTxn(OperationContext* opCtx, + const NamespaceString& nss, + TxnNumber txnNumber); + + /** + * Deletes the 'timestamp' from the entry in config.collections matching nss, in a transaction. + * + * TODO SERVER-53283: Remove once 5.0 has been released. + */ + void _deleteConfigCollectionsTimestampInTxn(OperationContext* opCtx, + const NamespaceString& nss, + TxnNumber txnNumber); + + /** + * Sets the 'collectionUuid' field for the entries matching nss in config.chunks, in a + * transaction. + * + * TODO SERVER-53283: Remove once 5.0 has been released. + */ + void _createChunkCollUuidFor49InTxn(OperationContext* opCtx, + const NamespaceString& nss, + const mongo::UUID& collectionUuid, + TxnNumber txnNumber); + + /** + * Deletes the 'collectionUuid' field for the entries matching nss in config.chunks, in a + * transaction. + * + * TODO SERVER-53283: Remove once 5.0 has been released. + */ + void _deleteChunkCollUuidInTxn(OperationContext* opCtx, + const NamespaceString& nss, + TxnNumber txnNumber); + // The owning service context ServiceContext* const _serviceContext; |