Skip to content

Commit 1ac9c53

Browse files
pierlauroMongoDB Bot
authored andcommitted
SERVER-80188 Remove epoch from migration source manager once 8.0 becomes last-lts (#35323)
GitOrigin-RevId: fd4fdd60c6c52b2122cf8b82813225a96d9811f7
1 parent 556aff4 commit 1ac9c53

File tree

7 files changed

+30
-45
lines changed

7 files changed

+30
-45
lines changed

src/mongo/db/s/active_migrations_registry_test.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ ShardsvrMoveRange createMoveRangeRequest(const NamespaceString& nss,
6767
const OID& epoch = OID::gen()) {
6868
const ShardId fromShard = ShardId("shard0001");
6969
const long long maxChunkSizeBytes = 1024;
70-
ShardsvrMoveRange req(nss, fromShard, maxChunkSizeBytes);
71-
req.setEpoch(epoch);
70+
ShardsvrMoveRange req(nss, Timestamp(10), fromShard, maxChunkSizeBytes);
7271
req.getMoveRangeRequestBase().setToShard(ShardId("shard0002"));
7372
req.setMaxChunkSizeBytes(1024);
7473
req.getMoveRangeRequestBase().setMin(BSON("Key" << -100));

src/mongo/db/s/balancer/balancer.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,6 @@ void enqueueChunkMigrations(OperationContext* opCtx,
415415
shardSvrRequest.setMaxChunkSizeBytes(maxChunkSizeBytes);
416416
shardSvrRequest.setFromShard(migrateInfo.from);
417417
shardSvrRequest.setCollectionTimestamp(migrateInfo.version.getTimestamp());
418-
shardSvrRequest.setEpoch(migrateInfo.version.epoch());
419418
shardSvrRequest.setForceJumbo(migrateInfo.forceJumbo);
420419
const auto [secondaryThrottle, wc] =
421420
getSecondaryThrottleAndWriteConcern(balancerConfig->getSecondaryThrottle());
@@ -778,7 +777,6 @@ Status Balancer::moveRange(OperationContext* opCtx,
778777
shardSvrRequest.setMaxChunkSizeBytes(maxChunkSize);
779778
shardSvrRequest.setFromShard(fromShardId);
780779
shardSvrRequest.setCollectionTimestamp(coll.getTimestamp());
781-
shardSvrRequest.setEpoch(coll.getEpoch());
782780
const auto [secondaryThrottle, wc] =
783781
getSecondaryThrottleAndWriteConcern(request.getSecondaryThrottle());
784782
shardSvrRequest.setSecondaryThrottle(secondaryThrottle);

src/mongo/db/s/balancer/balancer_commands_scheduler_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class BalancerCommandsSchedulerTest : public ConfigServerTestFixture {
111111
shardSvrRequest.setDbName(DatabaseName::kAdmin);
112112
shardSvrRequest.setMoveRangeRequestBase(base);
113113
shardSvrRequest.setFromShard(from);
114-
shardSvrRequest.setEpoch(OID::gen());
114+
shardSvrRequest.setCollectionTimestamp(Timestamp(10));
115115
shardSvrRequest.setMaxChunkSizeBytes(1024 * 1024);
116116

117117
return shardSvrRequest;

src/mongo/db/s/migration_chunk_cloner_source_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ class MigrationChunkClonerSourceTest : public ShardServerTestFixture {
759759
*/
760760
static ShardsvrMoveRange createMoveRangeRequest(const ChunkRange& chunkRange) {
761761
ShardsvrMoveRange req(kNss);
762-
req.setEpoch(OID::gen());
762+
req.setCollectionTimestamp(Timestamp(10));
763763
req.setFromShard(ShardId(kDonorConnStr.getSetName()));
764764
req.setMaxChunkSizeBytes(1024);
765765
req.getMoveRangeRequestBase().setToShard(ShardId(kRecipientConnStr.getSetName()));

src/mongo/db/s/migration_source_manager.cpp

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/mongo/db/s/migration_source_manager.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,13 +288,11 @@ class MigrationSourceManager {
288288
};
289289
boost::optional<ScopedRegisterer> _scopedRegisterer;
290290

291-
// The epoch of the collection being migrated and its UUID, as of the time the migration
292-
// started. Values are boost::optional only up until the constructor runs, because UUID doesn't
293-
// have a default constructor.
294-
// TODO SERVER-80188: remove _collectionEpoch once 8.0 becomes last-lts.
295-
boost::optional<OID> _collectionEpoch;
291+
// The UUID and timesetamp of the collection being migrated. The UUID values is boost::optional
292+
// only up until the constructor runs, because UUID doesn't have a default constructor.
296293
boost::optional<UUID> _collectionUUID;
297-
boost::optional<Timestamp> _collectionTimestamp;
294+
295+
Timestamp _collectionTimestamp;
298296

299297
// The version of the chunk at the time the migration started.
300298
boost::optional<ChunkVersion> _chunkVersion;

src/mongo/s/request_types/move_range_request.idl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,9 @@ commands:
130130
chained_structs:
131131
MoveRangeRequestBase: MoveRangeRequestBase
132132
fields:
133-
# TODO SERVER-80188: remove _collectionEpoch once 8.0 becomes last-lts.
134-
epoch:
135-
type: objectid
136-
description: "Epoch of the collection"
137-
optional: true
138133
collectionTimestamp:
139134
type: timestamp
140135
description: "Timestamp of the collection"
141-
optional: true
142136
fromShard:
143137
type: shard_id
144138
description: "ID of the donor shard"

0 commit comments

Comments
 (0)