From 2d671ab90e0282773ea89f1860705503dd5bf74d Mon Sep 17 00:00:00 2001 From: Esha Maharishi Date: Thu, 3 Oct 2019 19:39:45 +0000 Subject: SERVER-39763 transactions_target_at_point_in_time.js should disable expiring old chunk history (cherry picked from commit 688368b4440c18bd048f122d8a729c26e9ad4a6e) --- jstests/sharding/transactions_target_at_point_in_time.js | 13 ++++++++++++- .../s/config/sharding_catalog_manager_chunk_operations.cpp | 11 +++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/jstests/sharding/transactions_target_at_point_in_time.js b/jstests/sharding/transactions_target_at_point_in_time.js index 3cdfb4b49fe..a09f5491622 100644 --- a/jstests/sharding/transactions_target_at_point_in_time.js +++ b/jstests/sharding/transactions_target_at_point_in_time.js @@ -24,7 +24,18 @@ const dbName = "test"; const collName = "foo"; const ns = dbName + '.' + collName; -const st = new ShardingTest({shards: 3, mongos: 1, config: 1}); +const st = new ShardingTest({ + shards: 3, + mongos: 1, + config: 1, + other: { + // Disable expiring old chunk history to ensure the transactions are able to read from a + // shard that has donated a chunk, even if the migration takes longer than the amount of + // time for which a chunk's history is normally stored (see SERVER-39763). + configOptions: + {setParameter: {"failpoint.skipExpiringOldChunkHistory": "{mode: 'alwaysOn'}"}} + } +}); // Set up one sharded collection with 2 chunks, both on the primary shard. 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 86aa76b89dc..a1bd16dc8b8 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 @@ -58,6 +58,7 @@ namespace mongo { namespace { MONGO_FAIL_POINT_DEFINE(migrationCommitVersionError); +MONGO_FAIL_POINT_DEFINE(skipExpiringOldChunkHistory); /** * Append min, max and version information from chunk to the buffer for logChange purposes. @@ -684,10 +685,12 @@ StatusWith ShardingCatalogManager::commitChunkMigration( // Update the history of the migrated chunk. // Drop the history that is too old (10 seconds of history for now). // TODO SERVER-33831 to update the old history removal policy. - while (!newHistory.empty() && - newHistory.back().getValidAfter().getSecs() + kHistorySecs < - validAfter.get().getSecs()) { - newHistory.pop_back(); + if (!MONGO_FAIL_POINT(skipExpiringOldChunkHistory)) { + while (!newHistory.empty() && + newHistory.back().getValidAfter().getSecs() + kHistorySecs < + validAfter.get().getSecs()) { + newHistory.pop_back(); + } } if (!newHistory.empty() && newHistory.front().getValidAfter() >= validAfter.get()) { -- cgit v1.2.1