[SERVER-76826] $merge doesn't work with document that has dollar fields Created: 03/May/23  Updated: 29/Oct/23  Resolved: 11/May/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.1.0-rc0, 7.0.0-rc1, 6.0.7, 5.0.19

Type: Bug Priority: Major - P3
Reporter: Rui Liu Assignee: Rui Liu
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Related
related to SERVER-76999 Generate consistent errors for updati... Backlog
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v7.0, v6.3, v6.0, v5.0, v4.4
Participants:
Linked BF Score: 135

 Description   

Currently, if the client document for merge has the first field starting with '$', it may be treated as a modifier style update, even when the intention is always a replacement style update. This triggered the invariant in the linked BF.

However, even if we fix the invariant, supporting $merge with dollar fields across the board is harder than expected. For example, if the merge strategy results in a modifier style update, having a dollar field in the updated document will trigger validation assertion down the line. Even if it's a replacement style update, it still may trigger validation assertion after experiments.

To be relatively consistent instead of only supporting dollar fields in some combination of merge strategies, we can also consider rejecting the dollar fields except for the pipeline style update.



 Comments   
Comment by Githook User [ 12/May/23 ]

Author:

{'name': 'Rui Liu', 'email': 'lriuui0x0@gmail.com', 'username': 'lriuui0x0'}

Message: SERVER-76826 Fix invariant failure for $merge with dollar fields

(cherry picked from commit f59655be727acb3c33b4183d2d70ceebb96fede2)
Branch: v5.0
https://github.com/mongodb/mongo/commit/d78cf7f7870d10bb15b907635c155419e7edc546

Comment by Githook User [ 12/May/23 ]

Author:

{'name': 'Rui Liu', 'email': 'lriuui0x0@gmail.com', 'username': 'lriuui0x0'}

Message: SERVER-76826 Fix invariant failure for $merge with dollar fields

(cherry picked from commit f59655be727acb3c33b4183d2d70ceebb96fede2)
Branch: v6.0
https://github.com/mongodb/mongo/commit/73825cf138d0b431ed6a6f1eb1de9daa0618c58d

Comment by Githook User [ 12/May/23 ]

Author:

{'name': 'Rui Liu', 'email': 'lriuui0x0@gmail.com', 'username': 'lriuui0x0'}

Message: SERVER-76826 Fix invariant failure for $merge with dollar fields

(cherry picked from commit f59655be727acb3c33b4183d2d70ceebb96fede2)
Branch: v7.0
https://github.com/mongodb/mongo/commit/803ab4b0955c48f635106db22d8302914ea49122

Comment by Githook User [ 11/May/23 ]

Author:

{'name': 'Rui Liu', 'email': 'lriuui0x0@gmail.com', 'username': 'lriuui0x0'}

Message: SERVER-76826 Fix invariant failure for $merge with dollar fields
Branch: master
https://github.com/mongodb/mongo/commit/f59655be727acb3c33b4183d2d70ceebb96fede2

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