diff options
author | Jack Mulrow <jack.mulrow@mongodb.com> | 2018-03-29 13:00:06 -0400 |
---|---|---|
committer | Jack Mulrow <jack.mulrow@mongodb.com> | 2018-04-09 12:22:43 -0400 |
commit | 54fc5c5686ed0a9bef3b388b760442d8a49e7d60 (patch) | |
tree | 00be1994eaf8f0dc6b10885ab5ba36e4f023b84c /src | |
parent | 7fd2310cdbad58393855d9a06e664a3fb6ecdbea (diff) | |
download | mongo-54fc5c5686ed0a9bef3b388b760442d8a49e7d60.tar.gz |
SERVER-34194 applyOps update for control chunk should include history array
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp | 1 | ||||
-rw-r--r-- | src/mongo/db/s/config/sharding_catalog_manager_commit_chunk_migration_test.cpp | 10 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp b/src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp index 50d25843d50..5f32fca980a 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp +++ b/src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp @@ -220,6 +220,7 @@ BSONObj makeCommitChunkTransactionCommand(const NamespaceString& nss, n.append(ChunkType::min(), controlChunk->getMin()); n.append(ChunkType::max(), controlChunk->getMax()); n.append(ChunkType::shard(), fromShard); + controlChunk->addHistoryToBSON(n); n.done(); BSONObjBuilder q(op.subobjStart("o2")); diff --git a/src/mongo/db/s/config/sharding_catalog_manager_commit_chunk_migration_test.cpp b/src/mongo/db/s/config/sharding_catalog_manager_commit_chunk_migration_test.cpp index 5a817120c27..7a8245b1306 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager_commit_chunk_migration_test.cpp +++ b/src/mongo/db/s/config/sharding_catalog_manager_commit_chunk_migration_test.cpp @@ -77,6 +77,9 @@ TEST_F(CommitChunkMigrate, CheckCorrectOpsCommandWithCtl) { chunk1.setVersion(origVersion); chunk1.setShard(shard0.getName()); + Timestamp ctrlChunkValidAfter = Timestamp(50, 0); + chunk1.setHistory({ChunkHistory(ctrlChunkValidAfter, shard0.getName())}); + chunk1.setMin(chunkMax); auto chunkMaxax = BSON("a" << 20); chunk1.setMax(chunkMaxax); @@ -115,13 +118,18 @@ TEST_F(CommitChunkMigrate, CheckCorrectOpsCommandWithCtl) { auto chunkDoc0 = uassertStatusOK(getChunkDoc(operationContext(), chunkMin)); ASSERT_EQ("shard1", chunkDoc0.getShard().toString()); ASSERT_EQ(mver.getValue(), chunkDoc0.getVersion()); - // The history should be updated. + + // The migrated chunk's history should be updated. ASSERT_EQ(2UL, chunkDoc0.getHistory().size()); ASSERT_EQ(validAfter, chunkDoc0.getHistory().front().getValidAfter()); auto chunkDoc1 = uassertStatusOK(getChunkDoc(operationContext(), chunkMax)); ASSERT_EQ("shard0", chunkDoc1.getShard().toString()); ASSERT_EQ(cver.getValue(), chunkDoc1.getVersion()); + + // The control chunk's history should be unchanged. + ASSERT_EQ(1UL, chunkDoc1.getHistory().size()); + ASSERT_EQ(ctrlChunkValidAfter, chunkDoc1.getHistory().front().getValidAfter()); } TEST_F(CommitChunkMigrate, CheckCorrectOpsCommandNoCtl) { |