-
Type: Task
-
Resolution: Fixed
-
Priority: Major - P3
-
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.
- is depended on by
-
SERVER-68759 Make analyzeShardKey command calculate metrics about the shard key updates
- Closed
- is related to
-
SERVER-69237 Make the preImage document always available to CollectionUpdateArgs from UpdateStage
- Closed