diff --git a/src/mongo/db/sessions_collection.cpp b/src/mongo/db/sessions_collection.cpp
|
index 88c75302220..38d35720ca4 100644
|
--- a/src/mongo/db/sessions_collection.cpp
|
+++ b/src/mongo/db/sessions_collection.cpp
|
@@ -43,8 +43,11 @@
|
#include "mongo/db/repl/read_concern_args.h"
|
#include "mongo/rpc/get_status_from_command_result.h"
|
#include "mongo/s/write_ops/batched_command_response.h"
|
+#include "mongo/util/fail_point.h"
|
|
namespace mongo {
|
+
|
+MONGO_FAIL_POINT_DEFINE(sessionsCollectionMakeBadCreateIndexCommand);
|
namespace {
|
|
// This batch size is chosen to ensure that we don't form requests larger than the 16mb limit.
|
@@ -276,7 +279,13 @@ BSONObj SessionsCollection::generateCreateIndexesCmd() {
|
index.setExpireAfterSeconds(localLogicalSessionTimeoutMinutes * 60);
|
|
CreateIndexesCommand createIndexes(NamespaceString::kLogicalSessionsNamespace);
|
- createIndexes.setIndexes({index.toBSON()});
|
+ auto indexBson = index.toBSON();
|
+ sessionsCollectionMakeBadCreateIndexCommand.execute([&](const BSONObj& data) {
|
+ auto tmp = BSON("expireAfterSeconds"
|
+ << "badValue");
|
+ indexBson = indexBson.addField(tmp.firstElement());
|
+ });
|
+ createIndexes.setIndexes({indexBson});
|
|
return createIndexes.toBSON(BSON(WriteConcernOptions::kWriteConcernField
|
<< WriteConcernOptions::kInternalWriteDefault));
|
diff --git a/src/mongo/shell/shardingtest.js b/src/mongo/shell/shardingtest.js
|
index dc55d3b0a5e..135fcadd430 100644
|
--- a/src/mongo/shell/shardingtest.js
|
+++ b/src/mongo/shell/shardingtest.js
|
@@ -1916,7 +1916,10 @@ var ShardingTest = function(params) {
|
// Ensure that the sessions collection exists so jstests can run things with
|
// logical sessions and test them. We do this by forcing an immediate cache refresh
|
// on the config server, which auto-shards the collection for the cluster.
|
- this.configRS.getPrimary().getDB("admin").runCommand({refreshLogicalSessionCacheNow: 1});
|
+ assert.commandWorked(this.configRS.getPrimary().getDB("admin").runCommand(
|
+ {configureFailPoint: "sessionsCollectionMakeBadCreateIndexCommand", mode: "alwaysOn"}));
|
+ assert.commandWorked(
|
+ this.configRS.getPrimary().getDB("admin").runCommand({refreshLogicalSessionCacheNow: 1}));
|
|
// Ensure that all CSRS nodes are up to date. This is strictly needed for tests that use
|
// multiple mongoses. In those cases, the first mongos initializes the contents of the 'config'
|