Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-50701

Audit and cleanup uses of AutoGetCollection::getCollection

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Catalog and Routing
    • 2

      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.

            Assignee:
            Unassigned Unassigned
            Reporter:
            henrik.edin@mongodb.com Henrik Edin
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: