diff options
author | Alex Taskov <alex.taskov@mongodb.com> | 2021-03-26 09:12:58 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-03-26 14:02:26 +0000 |
commit | 28c0c1be5617a6c806593b5ac0ad4f90d2544985 (patch) | |
tree | 94794dff11670fa9ddcef7cc2f96968fb315aa3b /src/mongo/db/s/resharding/resharding_donor_recipient_common.cpp | |
parent | 37a20b4bef1ea9ebb8a433ccc67de32e63c8fecc (diff) | |
download | mongo-28c0c1be5617a6c806593b5ac0ad4f90d2544985.tar.gz |
SERVER-54279 Add database primary as recipient in resharding
Diffstat (limited to 'src/mongo/db/s/resharding/resharding_donor_recipient_common.cpp')
-rw-r--r-- | src/mongo/db/s/resharding/resharding_donor_recipient_common.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/mongo/db/s/resharding/resharding_donor_recipient_common.cpp b/src/mongo/db/s/resharding/resharding_donor_recipient_common.cpp index 9b577a4f59f..df03a16bddb 100644 --- a/src/mongo/db/s/resharding/resharding_donor_recipient_common.cpp +++ b/src/mongo/db/s/resharding/resharding_donor_recipient_common.cpp @@ -208,6 +208,10 @@ void processReshardingFieldsForDonorCollection(OperationContext* opCtx, ReshardingDonorDocument>(opCtx, donorDoc); } +bool isCurrentShardPrimary(OperationContext* opCtx, const CollectionMetadata& metadata) { + return metadata.getChunkManager()->dbPrimary() == ShardingState::get(opCtx)->shardId(); +} + /* * Either constructs a new ReshardingRecipientStateMachine with 'reshardingFields' or passes * 'reshardingFields' to an already-existing ReshardingRecipientStateMachine. @@ -243,7 +247,7 @@ void processReshardingFieldsForRecipientCollection(OperationContext* opCtx, // This could be a shard not indicated as a recipient that's trying to refresh the temporary // collection. In this case, we don't want to create a recipient machine. - if (!metadata.currentShardHasAnyChunks()) { + if (!isCurrentShardPrimary(opCtx, metadata) && !metadata.currentShardHasAnyChunks()) { return; } |