[SERVER-79442] Update command may send mirrored reads without filter, hint or collation Created: 27/Jul/23  Updated: 01/Aug/23

Status: Backlog
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Wenbin Zhu Assignee: Backlog - Service Architecture
Resolution: Unresolved Votes: 0
Labels: techdebt
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Service Arch
Operating System: ALL
Participants:

 Description   

Currently update command only sets _updateOpObj when the `updates` DocumentSequence is present in OpMsg. However this is often not the case, especially due to SERVER-77648 which means that all update commands sent from mongos to mongod are serialized in a way that does not have any DocumentSequence in OpMsg (this can be verified by doing a simple update through mongos in a sharded cluster).
 
Without correctly setting _updateOpObj, the mirrored read requests sent to secondaries will not have filter, hint or collation, and this means that the documents we put into secondary's cache will not be the same as user read on primary. This might have negative impact on the effectiveness of cache warmup.



 Comments   
Comment by Wenbin Zhu [ 28/Jul/23 ]

Yeah I also suspected internal update commands being one of the reason.

Comment by Kaitlin Mahar [ 28/Jul/23 ]

wenbin.zhu@mongodb.com Ah I see. Thanks. Yes, there are a lot of failures. I know there are some cases mongod generates update commands internally like for aggregate with $merge so that could explain some of the failures.

Comment by Wenbin Zhu [ 28/Jul/23 ]

Can you clarify in what case that happens in a replica set? Who is sending the command to the primary?

I observed this because I changed this code to invariant that the `updates` DocumentSequence is always present in OpMsgRequest (patch), and I saw a lot of failures in the canary patch build where the replica set tests are also failing, but I'm not clear about the reason behind.

Comment by Kaitlin Mahar [ 28/Jul/23 ]

wenbin.zhu@mongodb.com:

it seems that this can even happen in a replica set

Can you clarify in what case that happens in a replica set? Who is sending the command to the primary?

Comment by Wenbin Zhu [ 27/Jul/23 ]

Moreover SERVER-77648 talks about the case that a update command can be serialized to OpMsg without having DocumentSequence when the command is sent from mongos, however it seems that this can even happen in a replica set, this might need separate investigation.

Comment by Wenbin Zhu [ 27/Jul/23 ]

A couple of point from the offline discussion with amirsaman.memaripour@mongodb.com:

  • Even with this problem, we might still have enough in WiredTiger cache to have a smooth transition after the election (e.g., the top levels of the B-Tree for the collection will end up being in the cache anyway)
  • We never measured the effectiveness of mirror reads, this needs more product discussion.

cc shameek.ray@mongodb.com 

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