[SERVER-68128] Exceptions thrown while generating command response lead to network error Created: 19/Jul/22  Updated: 29/Oct/23  Resolved: 31/Oct/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 5.0.6, 6.0.0-rc13
Fix Version/s: 6.2.0-rc0

Type: Bug Priority: Major - P3
Reporter: Tommaso Tocci Assignee: Jason Chan
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v6.0, v5.0
Sprint: Service Arch 2022-10-17, Service Arch 2022-10-31, Service Arch 2022-11-14
Participants:
Case:

 Description   

If an exception is thrown inside makeCommandResponse the error will be simply logged in onHandleRequestException the connection will be closed and the client will receive a network error instead of the original one.
I think this behavior is misleading and makes very difficult to debug even simple errors.

For instance, if the size of the generated response for the command is bigger than 16MiB, we will throw a BSONObjectTooLarge when we try to serialize it. In this case I would expect this error to be propagated to the client rather than simply closing the connection.

Example:

[js_test:shard_collection_basic] d22020| 2022-07-19T13:06:48.464+00:00 E  COMMAND  4879802 [conn1] Failed to handle request{"error":"BSONObjectTooLarge: BSON size limit hit while building Message. Size: 26214739 (0x1900153); maxSize: 16793600(16MB)"}
[js_test:shard_collection_basic] d22020| 2022-07-19T13:06:48.528+00:00 I  NETWORK  22944 [conn1] Connection ended{"remote":"127.0.0.1:41766","uuid":"7307a252-7dfb-46ac-af96-f07b460bb18b","connectionId":1,"connectionCount":13}
[js_test:shard_collection_basic] uncaught exception: Error: error doing query: failed: network error while attempting to run command 'autoSplitVector' on host '127.0.0.1:22020'  :



 Comments   
Comment by Githook User [ 31/Oct/22 ]

Author:

{'name': 'Jason Chan', 'email': 'jason.chan@mongodb.com', 'username': 'jasonjhchan'}

Message: SERVER-68128 Avoid closing connections when generating command response throws BSONObjectTooLarge
Branch: master
https://github.com/mongodb/mongo/commit/b220a5176b0b70a158d483d8cbf8ab7d7744c5a1

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