summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Chan <jason.chan@mongodb.com>2021-01-27 19:20:31 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-02-17 22:19:15 +0000
commitc8ab2de5e1c1dea00aa7506efd19d4aabd92bf0f (patch)
tree55a06103ce3efc785e40da6bfb732b1ef9e600c6
parent4fb715053b3ad308c85501e9e9d0a1169bc78556 (diff)
downloadmongo-c8ab2de5e1c1dea00aa7506efd19d4aabd92bf0f.tar.gz
SERVER-53831 Force SpiderMonkey to garbage collect in ReplSetTest.checkOplogs
(cherry picked from commit 96fe72c36d370a4067240738f051021d4daf72ce)
-rw-r--r--src/mongo/shell/replsettest.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/mongo/shell/replsettest.js b/src/mongo/shell/replsettest.js
index 481c1f60339..1017d5072ce 100644
--- a/src/mongo/shell/replsettest.js
+++ b/src/mongo/shell/replsettest.js
@@ -2268,8 +2268,13 @@ var ReplSetTest = function(opts) {
const firstReader = readers[firstReaderIndex];
let prevOplogEntry;
assert(firstReader.hasNext(), "oplog is empty while checkOplogs is called");
+ // Track the number of bytes we are reading as we check the oplog. We use this to avoid
+ // out-of-memory issues by calling to garbage collect whenever the memory footprint is
+ // large.
+ let bytesSinceGC = 0;
while (firstReader.hasNext()) {
const oplogEntry = firstReader.next();
+ bytesSinceGC += Object.bsonsize(oplogEntry);
if (oplogEntry === kCappedPositionLostSentinel) {
// When using legacy OP_QUERY/OP_GET_MORE reads against mongos, it is
// possible for hasNext() to return true but for next() to throw an exception.
@@ -2284,6 +2289,7 @@ var ReplSetTest = function(opts) {
}
const otherOplogEntry = readers[i].next();
+ bytesSinceGC += Object.bsonsize(otherOplogEntry);
if (otherOplogEntry && otherOplogEntry !== kCappedPositionLostSentinel) {
assertOplogEntriesEq.call(this,
oplogEntry,
@@ -2293,6 +2299,11 @@ var ReplSetTest = function(opts) {
prevOplogEntry);
}
}
+ // Garbage collect every 10MB.
+ if (bytesSinceGC > (10 * 1024 * 1024)) {
+ gc();
+ bytesSinceGC = 0;
+ }
prevOplogEntry = oplogEntry;
}
}