[SERVER-80853] $out on secondary node can produce incorrect results if primary steps down Created: 07/Sep/23  Updated: 16/Jan/24

Status: In Code Review
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Jordi Serra Torrens Assignee: Parker Felix
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File 0001-Repro-SERVER-80853.patch    
Issue Links:
Related
related to SERVER-38852 Failing $merge can leave zombie write... Backlog
related to SERVER-43198 Zombie writes from failing $merge sho... Backlog
is related to SERVER-75856 Support implicit database creation fo... In Code Review
Assigned Teams:
Query Execution
Operating System: ALL
Participants:

 Description   

1. $out starts on a secondary. It creates a `temp` collection and starts writing to it.
2. Election happens and a new primary steps up. On stepup `temp` collections are dropped.
3. $out on the secondary continues running and will start targeting upcoming inserts to the new primary.
4. Since the `temp` collection has been dropped on step (2), the write at (3) will implicitly recreate it.
5. $out finishes successfully, but documents written before step (2) are missing.



 Comments   
Comment by Katya Kamenieva [ 03/Oct/23 ]

The issue is that the failure is not reported. It looks like a successful operation to the user. It should produce an error.

Comment by Mihai Andrei [ 03/Oct/23 ]

Note that this was a known limitation when this feature was implemented during the 4.4 release cycle. From the scope:
> Allow $out or $merge to survive stepdowns. These operations may still fail with a NotMaster error if a stepdown occurs during execution.

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