summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEsha Maharishi <esha.maharishi@mongodb.com>2019-10-03 19:39:45 +0000
committerevergreen <evergreen@mongodb.com>2019-10-03 19:39:45 +0000
commit2d671ab90e0282773ea89f1860705503dd5bf74d (patch)
tree13f060fcd7062f50ce251b8f7d9bf1055fd22c9f
parentbc734bbd61ea5e07301f1f05c83db08641453201 (diff)
downloadmongo-2d671ab90e0282773ea89f1860705503dd5bf74d.tar.gz
SERVER-39763 transactions_target_at_point_in_time.js should disable expiring old chunk history
(cherry picked from commit 688368b4440c18bd048f122d8a729c26e9ad4a6e)
-rw-r--r--jstests/sharding/transactions_target_at_point_in_time.js13
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp11
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()) {