Operational Defect Database

BugZero found this defect 191 days ago.

MongoDB | 2497214

Shared buffer fragment incorrectly tracks memory usage in freeUnused()

Last update date:

3/14/2024

Affected products:

MongoDB Server

Affected releases:

6.0.4

6.2.0-rc0

Fixed releases:

7.0.6

6.0.14

8.0.0-rc0

7.3.0-rc2

Description:

Info

We decrement from memUsage when we free unused buffers from _activeBuffers here. The calculation is incorrect and undercounts actual freed memory causing the memUsage stat to balloon. This can be a problem when the memusage stat grows past the in-memory limit for the sorter resulting in spilling to disk on every key added to the sorter, eventually leading to an OOM issue.

Top User Comments

xgen-internal-githook commented on Thu, 14 Mar 2024 22:29:08 +0000: Author: {'name': 'Louis Williams', 'email': 'louiswilliams@users.noreply.github.com', 'username': 'louiswilliams'} Message: SERVER-83145 Correctly track memory usage in SharedBufferFragment (#18234) GitOrigin-RevId: 6c4aec482bb15f917219a01aec332de557f77ac8 Branch: v7.4test https://github.com/mongodb/mongo/commit/93186ed425ed477fdc581434bfe37f0f345a43c2 xgen-internal-githook commented on Mon, 29 Jan 2024 19:52:40 +0000: Author: {'name': 'Louis Williams', 'email': 'louiswilliams@users.noreply.github.com', 'username': 'louiswilliams'} Message: SERVER-83145 Correctly track memory usage in SharedBufferFragment (#18234) GitOrigin-RevId: cf21f604fdeef621f7782092ad637a89e57e1549 Branch: v6.0 https://github.com/mongodb/mongo/commit/1b600236e98f6d5e84df36611df2b2b6d79aa896 xgen-internal-githook commented on Fri, 26 Jan 2024 19:23:59 +0000: Author: {'name': 'Louis Williams', 'email': 'louiswilliams@users.noreply.github.com', 'username': 'louiswilliams'} Message: SERVER-83145 Correctly track memory usage in SharedBufferFragment (#18234) GitOrigin-RevId: 6c4aec482bb15f917219a01aec332de557f77ac8 Branch: v7.3 https://github.com/mongodb/mongo/commit/e76c1f5de4438982de8028668e3dd7a1b8797c39 xgen-internal-githook commented on Fri, 26 Jan 2024 19:11:55 +0000: Author: {'name': 'Louis Williams', 'email': 'louiswilliams@users.noreply.github.com', 'username': 'louiswilliams'} Message: SERVER-83145 Correctly track memory usage in SharedBufferFragment (#18234) GitOrigin-RevId: e6685de50d2a7556e2f2f9a8c52d30145d1256c9 Branch: v7.0 https://github.com/mongodb/mongo/commit/f880039d428b51a1260b65a1524cb5f30f2a19eb xgen-internal-githook commented on Thu, 25 Jan 2024 18:10:50 +0000: Author: {'name': 'Louis Williams', 'email': 'louiswilliams@users.noreply.github.com', 'username': 'louiswilliams'} Message: SERVER-83145 Correctly track memory usage in SharedBufferFragment (#18234) GitOrigin-RevId: 4ea6987aa035bbb75cf585b7390f70e5921b9ac5 Branch: master https://github.com/mongodb/mongo/commit/51d0db82a4b3f89fc031898d944d6c8f1088f1b2

Steps to Reproduce

const maxMemUsageMB = 50; const replSet = new ReplSetTest({ nodes: 1, nodeOptions: { setParameter: \{maxIndexBuildMemoryUsageMegabytes: maxMemUsageMB, heapProfilingEnabled: true} }, }); replSet.startSet(); replSet.initiate(); const primary = replSet.getPrimary(); const testDB = primary.getDB('test'); const coll = testDB.index_build_wildcard; const docs = 1000; const bigArr = new Array(100000).fill('x'.repeat(10)); let d = 0; while (d constbulk=coll.initializeUnorderedBulkOp(); for (leti=0; i { bulk.insert(\{a: (d+i) +'x'.repeat(1000), arr: bigArr} ); } d+=10; print(d); assert.commandWorked(bulk.execute()); } coll.createIndex({"$**": 1});

Additional Resources / Links

Share:

BugZero® Risk Score

What's this?

Coming soon

Status

Closed

Learn More

Search:

...