-
Type:
Bug
-
Resolution: Duplicate
-
Priority:
Major - P3
-
None
-
Affects Version/s: 4.4.29, 8.0.23, 5.0.34, 7.0.37, 6.0.30
-
Component/s: None
-
None
-
Networking & Observability
-
ALL
-
-
None
-
None
-
None
-
None
-
None
-
None
-
None
When Mirror Reads is enabled in a sharded cluster, update operations routed through mongos may lose their update predicate during mirror request generation.
We observed different behavior between:
- Client -> mongod
- Client -> mongos -> mongod
For the same update operation, direct connections to mongod correctly preserve the update filter in mirrored requests. However, when the request is routed through mongos, the mirrored request generated on the secondary appears to lose the original filter predicate, resulting in a collection scan.
Packet captures show that the root cause is related to different but semantically equivalent OP_MSG encodings.
PyMongo sends update commands using an OP_MSG Document Sequence:
{{Body
Document Sequence ("updates")}}
In this form, Mirror Reads correctly extracts the update predicate from the updates section.
After the request passes through mongos, mongos rewrites the command into an inline OP_MSG representation:
{{{
update: "users",
updates: [
{
q:
,
u: { $set:
}
}
]
}}}
In this representation, the updates information is embedded directly in the Body section and no Document Sequence exists.
Although both encodings are valid OP_MSG representations of the same update command, Mirror Reads appears to only extract predicates from the Document Sequence representation. When the command is rewritten into inline format by mongos, the predicate is no longer correctly propagated into the mirrored request.
As a result, filtered update operations routed through mongos may generate mirrored reads without the original filter, causing unnecessary collection scans on secondary nodes and creating behavior that differs from direct-to-mongod execution.
Mirror Reads should generate equivalent mirrored requests regardless of whether the update command is encoded using:
- OP_MSG Document Sequence ("updates")
- Inline updates array in the Body section
Both representations are protocol-valid and semantically equivalent.
- duplicates
-
SERVER-79442 Update command may send mirrored reads without filter, hint or collation
-
- Needs Merge
-
- is related to
-
SERVER-79442 Update command may send mirrored reads without filter, hint or collation
-
- Needs Merge
-