summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2022-08-28 08:31:07 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-10-11 16:41:14 +0000
commit2c5fa4b410d0d2b257df2b32f262fa92cf200ea1 (patch)
tree2c145fb3e899aa0113e32ebba8a4bac852d8267a /jstests
parent1c970f7c593cfe5ffd3a8ed29cee51ef0a3dffe5 (diff)
downloadmongo-2c5fa4b410d0d2b257df2b32f262fa92cf200ea1.tar.gz
SERVER-68477 listIndexes repairs TTL indexes with NaN expireAfterSeconds
(cherry picked from commit d6528bf96f08b79ca850902b2d1d81264fa7baa1)
Diffstat (limited to 'jstests')
-rw-r--r--jstests/noPassthrough/ttl_expire_nan.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/jstests/noPassthrough/ttl_expire_nan.js b/jstests/noPassthrough/ttl_expire_nan.js
index 5d26b214487..6b8ff73d015 100644
--- a/jstests/noPassthrough/ttl_expire_nan.js
+++ b/jstests/noPassthrough/ttl_expire_nan.js
@@ -11,9 +11,13 @@
(function() {
'use strict';
+load('jstests/noPassthrough/libs/index_build.js');
+
const rst = new ReplSetTest({
nodes: [{}, {rsConfig: {votes: 0, priority: 0}}],
nodeOptions: {setParameter: {ttlMonitorSleepSecs: 5}},
+ // Sync from primary only so that we have a well-defined node to check listIndexes behavior.
+ settings: {chainingAllowed: false},
});
rst.startSet();
rst.initiate();
@@ -41,5 +45,25 @@ checkLog.containsJson(secondary, 20384, {
assert.eq(
coll.countDocuments({}), 1, 'ttl index with NaN duration should not remove any documents.');
+// Confirm that TTL index is replicated with a non-zero 'expireAfterSeconds' during initial sync.
+const newNode = rst.add({rsConfig: {votes: 0, priority: 0}});
+rst.reInitiate();
+rst.waitForState(newNode, ReplSetTest.State.SECONDARY);
+rst.awaitReplication();
+let newNodeTestDB = newNode.getDB(db.getName());
+let newNodeColl = newNodeTestDB.getCollection(coll.getName());
+const newNodeIndexes = IndexBuildTest.assertIndexes(newNodeColl, 2, ['_id_', 't_1']);
+const newNodeSpec = newNodeIndexes.t_1;
+jsTestLog('TTL index on initial sync node: ' + tojson(newNodeSpec));
+assert(newNodeSpec.hasOwnProperty('expireAfterSeconds'),
+ 'Index was not replicated as a TTL index during initial sync.');
+assert.gt(newNodeSpec.expireAfterSeconds,
+ 0,
+ 'NaN expireAferSeconds was replicated as zero during initial sync.');
+
+// Check that listIndexes on the primary logged a "Fixing expire field from TTL index spec" message
+// during the NaN 'expireAfterSeconds' conversion.
+checkLog.containsJson(primary, 6835900, {namespace: coll.getFullName()});
+
rst.stopSet();
})();