- 
    Type:Task 
- 
    Resolution: Unresolved
- 
    Priority:Major - P3 
- 
    None
- 
    Affects Version/s: None
- 
    Component/s: None
- 
    None
- 
        Cluster Scalability
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
The resharding service has a common pattern where we create a CancelableOperationContextFactory and pass it the root cancelToken. This means that everytime we call CancelableOperationContextFactory::makeOperationContext, we end up creating new listeners to that token. This is known to be problematic due to SERVER-103945.
We should instead create hierarchies, like create new child token in certain parts of resharding in order to limit attaching new listeners to the root cancelToken. These child token will still need to be attached to the root token, but the grand children will attach to it (instead of the root token) so it should limit the memory usage since the memory usage associated with tokens tied to the grandchildren can be freed when it goes away.
- is depended on by
- 
                    SERVER-113062 Address use of long lived CancellationSources in Cluster Scalability code -         
- Needs Scheduling
 
-         
- is related to
- 
                    SERVER-111417 Investigate Possible Memory Leak During Resharding Applying -         
- Closed
 
-         
- 
                    SERVER-103945 Better memory management for CancellationToken -         
- Backlog
 
-         
- related to
- 
                    SERVER-111417 Investigate Possible Memory Leak During Resharding Applying -         
- Closed
 
-         
- 
                    SERVER-103945 Better memory management for CancellationToken -         
- Backlog
 
-