diff options
author | Christopher Caplinger <christopher.caplinger@mongodb.com> | 2022-03-14 15:02:12 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-03-14 16:17:10 +0000 |
commit | 1512c333827379f6ae74a4e2cceeaadbe768ba04 (patch) | |
tree | 53455a7d9296f17d957a9f169167a9de4e7dbf53 | |
parent | 237b218974e4fc09104c81fe0bb1ba83688d8035 (diff) | |
download | mongo-1512c333827379f6ae74a4e2cceeaadbe768ba04.tar.gz |
SERVER-64456: Use countDocuments() instead of count() to ensure accurate document count
-rw-r--r-- | jstests/replsets/tenant_migration_collection_ttl.js | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/jstests/replsets/tenant_migration_collection_ttl.js b/jstests/replsets/tenant_migration_collection_ttl.js index e76196b4fa4..6571e08c214 100644 --- a/jstests/replsets/tenant_migration_collection_ttl.js +++ b/jstests/replsets/tenant_migration_collection_ttl.js @@ -77,7 +77,13 @@ function waitForOneTTLPassAtNode(node) { } function getDocumentCount(dbName, node) { - return node.getDB(dbName)[collName].count(); + // Use "countDocuments" instead of "count" to ensure that we get an accurate + // count instead of an approximate count from metadata. Otherwise, the count + // can be inaccurate if a TTL pass happens concurrently with the count call when + // the access blocker is blocking writes. In this case, the TTL delete will fail and + // be rolled back, but count calls before the rollback is applied will still reflect + // the delete. + return node.getDB(dbName)[collName].countDocuments({}); } function assertTTLNotDeleteExpiredDocs(dbName, node) { |