[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: |
|
||||||||||||||||||||||||
| Driver Compliance: |
|
||||||||||||||||||||||||
| 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 | |
| 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 | |
| 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:
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. |