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

Add a helper for finding modified field names from pre and post images

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 6.2.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Fully Compatible
    • Sharding 2022-10-03

      To calculate the percentage of shard key updates, during query sampling we will need to additionally write down what fields each update modified. SERVER-69237 will allow the OpObserver to always have access to both the pre-image and post-image. Given this, we can compute the $v2 diff for each update using the doc_diff::computeDiff() helper. However, the format of the returned diff does not meet our use case for the following the reasons:

      • The diff is recursive. That is, the diff for each object and array field is itself a $v2 diff and the field name is prefixed by "s". Please see this section of the design document for PM-1460 for more details.
      • The diff contains the new values for each updated field. The values are not needed in our use case and can cause the diff to exceed the 16MB BSON size limit.

      This ticket is to add a helper that takes in pre and post images and serializes the DocumentSubDiffNode returned by computeDocDiff() into a BSONObj diff of the following format:

      {   <fieldName>: 'i'|'u'|'d',   <arrFieldName>: 'i'|'u'|'d',   <objFieldName>: {     <fieldName>: 'i'|'u'|'d',     ...,   },   ...} 

      That is, the diff will have the same schema as the document that the update modifies. The value of each field will be set to either 'i', 'u' or 'd' to indicate that the field was inserted, updated and deleted, respectively. The fields that did not change will not show up in the diff.

            Assignee:
            cheahuychou.mao@mongodb.com Cheahuychou Mao
            Reporter:
            cheahuychou.mao@mongodb.com Cheahuychou Mao
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: