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

Make the preImage document always available to CollectionUpdateArgs from UpdateStage

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 6.3.0-rc0
    • Affects Version/s: None
    • Component/s: Write Ops
    • None
    • Fully Compatible
    • Sharding NYC 2022-10-31, Sharding NYC 2022-11-14, Sharding NYC 2022-11-28

      CollectionUpdateArgs currently has a boost::optional<BSONObj> preImageDoc member representing the state of the document before the update occurred. For storage engines supporting document-level concurrency, the preImage document is always copied out of the storage engine before applying the update. This means that, since the removal of the MMAPv1 storage engine in MongoDB 4.2, CollectionUpdateArgs::preImageDoc can be non-optional.

      // Ensure that the BSONObj underlying the WorkingSetMember is owned because saveState()
      // is allowed to free the memory.
      member->makeObjOwnedIfNeeded();
      

      As part of these changes we should consider simplifying the places which attempted to carefully get an owned copy of the oldObj and newObj and instead make owned BSONObjs for them available inside and outside UpdateStage in an obvious way. Some areas which are ripe for refactoring include:

      Note that CollectionUpdateArgs::storeDocOption should continue to be StoreDocOption::kNone when the preImage document doesn't need to be stored in config.image_collection, etc.


      Side note: In the MMAPv1 storage engine, in-place updates were truly applied in-place meaning that the address of oldObj and the address of newObj were the same address.

            Assignee:
            israel.hsu@mongodb.com Israel Hsu
            Reporter:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Votes:
            1 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: