[DRIVERS-275] Drivers should check encoded operation size on client side Created: 19/Nov/15  Updated: 22/Feb/23  Resolved: 22/Feb/23

Status: Closed
Project: Drivers
Component/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Rathi Gnanasekaran Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on CDRIVER-589 Driver should sanity check the size o... Closed
depends on CXX-1483 Drivers should check encoded operatio... Closed
depends on GODRIVER-149 Drivers should check encoded operatio... Closed
Related
related to DRIVERS-276 Drivers must raise an error if respon... Closed
Driver Compliance:
Key Status/Resolution FixVersion
CDRIVER-589 Done 1.7.0
CXX-1483 Fixed
GODRIVER-149 Done

 Description   

While encoding operations to send to the server (OP_QUERY, OP_INSERT, ...) if the encoded operation exceeds a maximum number of bytes a driver MUST NOT send the operation to the server and MUST raise an error back to the application. For OP_INSERT the maximum size is ismaster.maxMessageSizeBytes. For all other operations the maximum size is ismaster.maxBsonObjectSize + 16k

Why?

Above a certain message size (tbd), instead of returning a useful error about oversize documents or messages the server just closes the socket. This makes debugging applications difficult since a socket being closed provides no information about what you did wrong.



 Comments   
Comment by Jeremy Mikola [ 18/Sep/17 ]

Validating PHPC since CDRIVER-589 is resolved. Not relevant to PHPLIB.

Comment by Jeremy Mikola [ 25/Nov/15 ]

Validated for legacy PHP driver (bson.c checks max document and message size and raises exceptions accordingly). I expect PHPC and HHVM validation will depend on CDRIVER-589.

Comment by A. Jesse Jiryu Davis [ 19/Nov/15 ]

LGTM, I don't think it's important to know at what size the server hangs up.

Comment by Bernie Hackett [ 19/Nov/15 ]

We can adjust when drivers support OP_COMMAND, but we should solve this problem for MongoDB <= 3.2 as well. I've updated the description with a mini spec.

Comment by David Golden [ 19/Nov/15 ]

Won't this change anyway under OP_COMMAND? My suggestion is that we get someone started writing a "Server Commands Spec" that covers both OP_COMMAND and legacy OP_QUERY (via some_db.$cmd) as we'll need one in a few months anyway.

In the meantime, I think the test is as simple as:

db.runCommand({x:LONG_STRING})

If x:LONG_STRING serializes to more than the max bson doc size + 16kb, then it should throw an exception.

See this commit for the Perl driver.

Comment by A. Jesse Jiryu Davis [ 19/Nov/15 ]

This needs a mini-spec, we can't validate our drivers until we write down what's meant by this ticket.

Generated at Thu Feb 08 08:21:09 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.