Need information about OP_MSG's more_to_come flag bit


I read the OP_MSG specifications in the wire protocol documentation and saw that there is a flag bit called more_to_come. I am trying to learn more about how this bit is toggled and how it would affect the requestID or responseTo fields for request/response messages. Is this bit commonly toggled? An example of a query to run to reproduce the scenario on wireshark would be great.

Thanks so much!!

From the server source code looks like this is a trigger for that flag:

Hi, @Kartik_Pattaswamy,

A good source of information is the moreToCome section of the OP_MSG spec. For a high-level overview of OP_MSG, I would recommend this blog post by one of our engineers.


Thanks a lot for the response. I realize that the more to come bit is set internally for bulk writes/find operations but what actually makes a bulk operation and causes the bit to be set by the client or server? I am trying to create a query that sets the bit and capture the traffic through wireshark.

The server will set the OP_MSG moreToCome flag on responses to exhaust cursors. Exhaust cursors are only valid for handshake messages (e.g. hello and legacy hello) and getMore. The easiest scenario to reproduce is to monitor the initial handshake between a 4.4-compatible driver and a 4.4 or later cluster. Streamable monitoring was introduced in 4.4. The initial handshake will start with OP_QUERY since the driver doesn’t know whether the cluster speaks OP_MSG. It will then upgrade to OP_MSG.

Another option is to opt into Stable API, which was introduced in MongoDB 5.0. Because we know the driver is talking to a MongoDB 5.0 cluster, the initial handshake is performed over OP_MSG.

I hope that this helps in your repro efforts.

Thanks a lot for the response. I was able to repro the server sending a message with moreToCome flag set. Is there also a way to repro the client also setting that flag on a request? I have tried inserting a document larger than the max BSON size as well sending a find query to receive many documents. Would I be right in assuming that this bit is usually set on server response?

A single document cannot exceed the maximum BSON size of 16MB. According to the spec, drivers can set moreToCome on a request for unacknowledged writes, but these are generally discouraged. Reviewing the .NET/C# Driver code, we do not set moreToCome for unacknowledged writes. Typically moreToCome is only set by the server.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.