[SERVER-40812] Allow replica set secondary node to batch apply same-node document shard key changes Created: 24/Apr/19  Updated: 29/Oct/23  Resolved: 30/Apr/19

Status: Closed
Project: Core Server
Component/s: Replication, Sharding
Affects Version/s: None
Fix Version/s: 4.1.11

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

Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Sharding 2019-05-06
Participants:

 Description   

Background:

  1. A primary node writes multiple same-node shard key updates.
  2. A second attempts to replicate, and is behind enough that it decides to batch apply instead of single apply.

Issue:
When the secondary attempts to apply each statement separately, it will see that the document shard key is changing, and will uassert because the opCtx is not in a transaction. It wouldn't be in a transaction, because the batch apply has no transaction associated with itself. This individual uassert leads to an fassert from the replication code.

Fix:
Add a check to !getOpCtx()->writesAreReplicated() in [this uassert here|https://github.com/mongodb/mongo/blob/406e1642a83d8b810bec41ad293c1b1c8a59a6dd/src/mongo/db/exec/update_stage.cpp#L929, so that we don't require the opCtx to have a transaction number if we are in a secondary node.



 Comments   
Comment by Githook User [ 30/Apr/19 ]

Author:

{'name': 'Blake Oler', 'username': 'BlakeIsBlake', 'email': 'blake.oler@mongodb.com'}

Message: SERVER-40812 Allow replica set secondary node to batch apply same-node document shard key changes
Branch: master
https://github.com/mongodb/mongo/commit/326fd668123f73c5e81ce597d58e40b569374820

Generated at Thu Feb 08 04:56:02 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.