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

Enforce writable collection usage through the CollectionWriter

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Catalog and Routing
    • CAR Team 2024-09-30
    • 2

      SERVER-94487 showed that the API offered through the Acquisitions for a writable collection is prone to misuse.

      Currently there are various ways to get a writable collection:

      • AutoGetCollection::getWritableCollection returns a non-const Collection instance and updates the internal CollectionPtr to point to it.
      • CollectionWriter is an adaptor over AutoGetCollection/CollecitonAcquisition that implicitly guarantees the underlying CollectionPtr will get updated once it goes out of scope.
      • CollectionCatalog::lookup*ForMetadataWrite returns a non-const Collection instance

      Ideally we would want users to only have one way of creating a writable collection via the CollectionWriter and to enforce no usage of the old CollectionPtr while the writer is in scope.

      To help users go through the expected path we should also offer some discoverability option in the acquisition API such that we can get a CollectionWriter from an existing AutoGet/Acquisition as a helper method.

            Assignee:
            sulabh.mahajan@mongodb.com Sulabh Mahajan
            Reporter:
            jordi.olivares-provencio@mongodb.com Jordi Olivares Provencio
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: