-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Networking & Observability
-
N&O Prioritized List
The OpMsg struct models the OP_MSG portion of a MongoDB wire protocol message. This struct does not include the flagbits however, which are OP_MSG-specific and not part of other Message types. In order to check and set these flags, one has to use static methods defined on OpMsg that operate over Message instances, which is unintuitive. It also can easily lead to bugs: checking for a flags presence just always returns false if the Message is not in fact an OP_MSG (even if it is an OP_COMPRESSED message with an underlying OP_MSG), and attempting to set a flag in that case hits an invariant. Further, parsing an OpMsg from a Message and then re-serializing it loses the flag bit information.
We should update OpMsg struct definition to include the flag bits, and rewrite the static flag-checking methods to instead be non-static. As part of this, we should update places in the code that are currently using Message but in reality can only work with OpMsg.