[SERVER-50701] Audit and cleanup uses of AutoGetCollection::getCollection Created: 02/Sep/20 Updated: 04/Dec/23 |
|
| Status: | Blocked |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Henrik Edin | Assignee: | Backlog - Catalog and Routing |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | car-qw, techdebt | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||
| Assigned Teams: |
Catalog and Routing
|
||||||||||||||||||||
| Participants: | |||||||||||||||||||||
| Story Points: | 2 | ||||||||||||||||||||
| Description |
|
AutoGetCollection now has operators making it behave like a smart pointer. With lock free reads it can be dangerous to call AutoGetCollection::getCollection and cache the returned pointer as a subsequent call to AutoGetCollection::getWritableCollection can invalidate the previous pointer. We should use operator-> and operator* on the AutoGetCollection when possible to encapsulate the Collection lifetime within the AutoGetCollection. While doing this we should also consider changing interfaces that pass along const Collection* to be const Collection&. That would make it clean to get the necessary type by just dereferencing the AutoGetCollection instance. Also while we are in here: consider renaming AutoGetCollection::getCollection() to AutoGetCollection::get() to make the interface more consistent with unique and shared pointer. As it is a Collection RAII type, the default return should be a Collection. |