@@ -199,8 +199,12 @@ MigrationSourceManager MigrationSourceManager::createMigrationSourceManager(
199199 AutoGetCollection autoColl (opCtx, nss, MODE_IS);
200200 const auto scopedCsr =
201201 CollectionShardingRuntime::assertCollectionLockedAndAcquireShared (opCtx, nss);
202- const auto [metadata, _] = checkCollectionIdentity (
203- opCtx, nss, args.getEpoch (), args.getCollectionTimestamp (), *autoColl, *scopedCsr);
202+ const auto [metadata, _] = checkCollectionIdentity (opCtx,
203+ nss,
204+ boost::none /* epoch */ ,
205+ args.getCollectionTimestamp (),
206+ *autoColl,
207+ *scopedCsr);
204208 return metadata;
205209 }();
206210
@@ -259,7 +263,8 @@ MigrationSourceManager::MigrationSourceManager(OperationContext* opCtx,
259263 _args.getMax(),
260264 6, // Total number of steps
261265 _args.getToShard(),
262- _args.getFromShard()) {
266+ _args.getFromShard()),
267+ _collectionTimestamp(_args.getCollectionTimestamp()) {
263268 // Since the MigrationSourceManager is registered on the CSR from the constructor, another
264269 // thread can get it and abort the migration (and get a reference to the completion promise's
265270 // future). When this happens, since we throw an exception from the constructor, the destructor
@@ -279,8 +284,12 @@ MigrationSourceManager::MigrationSourceManager(OperationContext* opCtx,
279284 auto scopedCsr =
280285 CollectionShardingRuntime::assertCollectionLockedAndAcquireExclusive (opCtx, nss ());
281286
282- auto [metadata, indexInfo] = checkCollectionIdentity (
283- _opCtx, nss (), _args.getEpoch (), _args.getCollectionTimestamp (), *autoColl, *scopedCsr);
287+ auto [metadata, indexInfo] = checkCollectionIdentity (_opCtx,
288+ nss (),
289+ boost::none /* epoch */ ,
290+ _args.getCollectionTimestamp (),
291+ *autoColl,
292+ *scopedCsr);
284293
285294 UUID collectionUUID = autoColl.getCollection ()->uuid ();
286295
@@ -350,9 +359,7 @@ MigrationSourceManager::MigrationSourceManager(OperationContext* opCtx,
350359 collectionIndexInfo,
351360 ChunkRange (*_args.getMin (), *_args.getMax ()));
352361
353- _collectionEpoch = _args.getEpoch ();
354362 _collectionUUID = collectionUUID;
355- _collectionTimestamp = _args.getCollectionTimestamp ();
356363
357364 _chunkVersion = collectionMetadata.getChunkManager ()
358365 ->findIntersectingChunkWithSimpleCollation (*_args.getMin ())
@@ -776,27 +783,16 @@ CollectionMetadata MigrationSourceManager::_getCurrentMetadataAndCheckForConflic
776783 optMetadata);
777784 return *optMetadata;
778785 }();
779- if (_collectionTimestamp) {
780- uassert (ErrorCodes::ConflictingOperationInProgress,
781- str::stream ()
782- << " The collection's timestamp has changed since the migration began. Expected "
783- " timestamp: "
784- << _collectionTimestamp->toStringPretty () << " , but found: "
785- << (metadata.isSharded ()
786- ? metadata.getCollPlacementVersion ().getTimestamp ().toStringPretty ()
787- : " unsharded collection" ),
788- metadata.isSharded () &&
789- *_collectionTimestamp == metadata.getCollPlacementVersion ().getTimestamp ());
790- } else {
791- uassert (
792- ErrorCodes::ConflictingOperationInProgress,
786+ uassert (ErrorCodes::ConflictingOperationInProgress,
793787 str::stream ()
794- << " The collection's epoch has changed since the migration began. Expected epoch: "
795- << _collectionEpoch->toString () << " , but found: "
796- << (metadata.isSharded () ? metadata.getCollPlacementVersion ().toString ()
797- : " unsharded collection" ),
798- metadata.isSharded () && metadata.getCollPlacementVersion ().epoch () == _collectionEpoch);
799- }
788+ << " The collection's timestamp has changed since the migration began. Expected "
789+ " timestamp: "
790+ << _collectionTimestamp.toStringPretty () << " , but found: "
791+ << (metadata.isSharded ()
792+ ? metadata.getCollPlacementVersion ().getTimestamp ().toStringPretty ()
793+ : " unsharded collection" ),
794+ metadata.isSharded () &&
795+ _collectionTimestamp == metadata.getCollPlacementVersion ().getTimestamp ());
800796
801797 return metadata;
802798}
0 commit comments