diff options
-rw-r--r-- | jstests/sharding/transactions_target_at_point_in_time.js | 13 | ||||
-rw-r--r-- | src/mongo/db/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<BSONObj> 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()) { |