diff options
author | Jason Chan <jason.chan@mongodb.com> | 2021-01-27 19:20:31 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-02-17 21:59:48 +0000 |
commit | 65d24ef61b0bc7549e687338a1e3b73b34f7f0f8 (patch) | |
tree | b7dd90aa7c8e553f07bddb17c9e29deb72eb9e4d | |
parent | f3cdc0e6d3bcd4c3780d584f3f6759f8cea51616 (diff) | |
download | mongo-65d24ef61b0bc7549e687338a1e3b73b34f7f0f8.tar.gz |
SERVER-53831 Force SpiderMonkey to garbage collect in ReplSetTest.checkOplogs
(cherry picked from commit 96fe72c36d370a4067240738f051021d4daf72ce)
-rw-r--r-- | src/mongo/shell/replsettest.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/mongo/shell/replsettest.js b/src/mongo/shell/replsettest.js index 322026ae417..156f2798171 100644 --- a/src/mongo/shell/replsettest.js +++ b/src/mongo/shell/replsettest.js @@ -2261,8 +2261,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. @@ -2277,6 +2282,7 @@ var ReplSetTest = function(opts) { } const otherOplogEntry = readers[i].next(); + bytesSinceGC += Object.bsonsize(otherOplogEntry); if (otherOplogEntry && otherOplogEntry !== kCappedPositionLostSentinel) { assertOplogEntriesEq.call(this, oplogEntry, @@ -2286,6 +2292,11 @@ var ReplSetTest = function(opts) { prevOplogEntry); } } + // Garbage collect every 10MB. + if (bytesSinceGC > (10 * 1024 * 1024)) { + gc(); + bytesSinceGC = 0; + } prevOplogEntry = oplogEntry; } } |