[SERVER-74427] Refactor lifetime of OplogCapMaintainerThread Created: 28/Feb/23 Updated: 29/Oct/23 Resolved: 03/Apr/23 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 7.0.0-rc0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Jordi Olivares Provencio | Assignee: | Jordi Olivares Provencio |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | techdebt | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Backwards Compatibility: | Fully Compatible |
| Sprint: | Execution Team 2023-03-20, Execution Team 2023-04-03, Execution Team 2023-04-17 |
| Participants: |
| Description |
|
Right now the thread gets spawned with a raw new and the pointer goes out of scope without ever being {{delete}}d. This is a literal memory leak that's harmless since it should only ever be deleted during shutdown. Nonetheless, we could refactor the code so at least it's lifetime is tied to the service context via a unique_ptr. |
| Comments |
| Comment by Githook User [ 03/Apr/23 ] |
|
Author: {'name': 'Jordi Olivares Provencio', 'email': 'jordi.olivares-provencio@mongodb.com', 'username': 'jordiolivares'}Message: |
| Comment by Jordi Olivares Provencio [ 28/Mar/23 ] |
|
The thread gets started as a self destructing BackgroundJob that never ends until shutdown. Theoretically this is fine since the thread will return when the server is in shutdown mode and thus self delete itself from the heap, clearing its memory usage. The problem with refactoring is that the thread gets blocked waiting inside the CollectionTruncateMarkers notification condition variable. This CV gets woken only if there's a new marker or the Oplog record store gets deleted. But the latter only happens once the Oplog RecordStore gets deleted during shutdown. |