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

Clean-up the use of empty DocumentStorage

    • Query Execution
    • 135

      The DocumentStorage class offers a public static const DocumentStorage& DocumentStorage::emptyDoc() method which returns a reference to a global private static const DocumentStorage::DocumentStorage kEmptyDoc.

      This public method is only used in private const DocumentStorage& Document::storage(), which returns a reference to the same global variable for all documents with empty storage pointer. IMHO, the whole thing should be avoided, unless there are some measurable benefits (e.g., performance).

      As an additional complication, the way the global variable is initialized exposes it to the theoretically possible "static initialization order fiasco".

      As an additional complication, class DocumentStorage contains mutable data members (and data members modified with const_cast), which increases the chance of having a data race.

      Moreover, Document::_storage is already an (intrusive) pointer, why to have and additional storage() method instead of pointing to the empty storage directly?

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            romans.kasperovics@mongodb.com Romans Kasperovics
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: