[SERVER-69474] Add a helper for finding modified field names from pre and post images Created: 06/Sep/22  Updated: 29/Oct/23  Resolved: 28/Sep/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 6.2.0-rc0

Type: Task Priority: Major - P3
Reporter: Cheahuychou Mao Assignee: Cheahuychou Mao
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-68759 Make analyzeShardKey command calculat... Closed
Related
is related to SERVER-69237 Make the preImage document always ava... Closed
Backwards Compatibility: Fully Compatible
Sprint: Sharding 2022-10-03
Participants:

 Description   

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.



 Comments   
Comment by Githook User [ 28/Sep/22 ]

Author:

{'name': 'Cheahuychou Mao', 'email': 'mao.cheahuychou@gmail.com', 'username': 'cheahuychou'}

Message: SERVER-69474 Add a helper for finding modified field names from pre and post images
Branch: master
https://github.com/mongodb/mongo/commit/911955a568b01620fcad0dfe35692862b4d4818f

Generated at Thu Feb 08 06:13:33 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.