[SERVER-61094] Generating KeyStrings from MultiIndexBlock can result in memory limits not being respected Created: 28/Oct/21 Updated: 29/Oct/23 Resolved: 02/Nov/21 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | 5.0.0 |
| Fix Version/s: | 5.2.0, 5.0.4, 5.1.0-rc3 |
| Type: | Bug | Priority: | Blocker - P1 |
| Reporter: | Henrik Edin | Assignee: | Henrik Edin |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||
| Operating System: | ALL | ||||||||||||||||
| Backport Requested: |
v5.1, v5.0
|
||||||||||||||||
| Sprint: | Execution Team 2021-11-15 | ||||||||||||||||
| Participants: | |||||||||||||||||
| Case: | (copied to CRM) | ||||||||||||||||
| Linked BF Score: | 135 | ||||||||||||||||
| Description |
|
When generating KeyString keys we use the KeyString::PooledBuilder that places multiple temporary KeyString on the same larger memory block to avoid multiple small allocations. Each KeyString holds a reference to the underlying memory that will not be free'd until all KeyString that is using it has been free'd. Normally this is fine as these KeyString are passed to the sorter that spills do disk when the memory consumption reach a certain threshold. As this process clears all temporary KeyString instances all memory blocks should be free'd. However, when there are multiple indexes being built at the same time these pooled memory blocks can be shared between KeyString instances belonging to different indexes. If some indexes generate large keys and need to be flushed to disk often the actual memory will not be free'd if there is still an index building that hasn't needed to spill to disk. |
| Comments |
| Comment by Githook User [ 02/Nov/21 ] |
|
Author: {'name': 'Henrik Edin', 'email': 'henrik.edin@mongodb.com', 'username': 'henrikedin'}Message: This avoids underlying SharedBuffer to be shared for KeyString for (cherry picked from commit 5d1078c60e8f24e027dc72d7ceeac4dab49908b9) |
| Comment by Githook User [ 02/Nov/21 ] |
|
Author: {'name': 'Henrik Edin', 'email': 'henrik.edin@mongodb.com', 'username': 'henrikedin'}Message: This avoids underlying SharedBuffer to be shared for KeyString for (cherry picked from commit 5d1078c60e8f24e027dc72d7ceeac4dab49908b9) |
| Comment by Githook User [ 01/Nov/21 ] |
|
Author: {'name': 'Henrik Edin', 'email': 'henrik.edin@mongodb.com', 'username': 'henrikedin'}Message: This avoids underlying SharedBuffer to be shared for KeyString for |