Description:
If using the X protocol you send messages protobuf messages wrapped in a 4-byte length indicator and a message type. The MySQL server itself has a limit on the size of the message. This is configurable but the default mysqlx_max_allowed_packet is 1MB.
If you send a packet that's over that size the server drops the connection and logs:
2016-09-05T17:22:23.204278Z 0 [Warning] Plugin mysqlx reported: '110: Message of size 4294967295 received, exceeding the limit of 1048576'
It does not actually tell the client what the problem is.
How to repeat:
Send something like: \0xff 5 times (4 times to give 2^32-1 message length and also a message type of 255 which is also illegal.
note: that MySQL does complain with this log line:
2016-09-05T18:02:19.456169Z 0 [Warning] Plugin mysqlx reported: '118: Message of size 4294967295 received, exceeding the limit of 1048576'
However no data is read back from the client and the connection is dropped.
Suggested fix:
This seems like an excellent way to make MySQL write lots of log info only by sending 5-bytes of packets to the server. So not ideal.
I'd expect:
* An error message to be sent back to the client telling it the mysql_max_allowed_packet has been exceeded. Perhaps this should depend on whether you are authenticated or not and if you are you get the mysqlx_max_allowed_packet value on the server as part of the message, if you're not logged in that information is not divulged?
* Logging might not be a good idea (by default) unless in a verbose debug mode on the server.
* Have a counter of "too long" messages.
* Ideally it would be good to have something in the protocol which allows client and server to negotiate/determine the others settings for this value. I've seen max_allowed_packet get exceeded because the "developer decided" to send a large SQL query but the mysql client library was not even aware this setting (being used) was too large. Avoiding that sort of mistake would be good in the MySQL X protocol as the client library could potentially avoid the large packet from ever being sent.
* Improve X protocol documentation to make it clear what minimum value is to be expected for mysqlx_max_allowed_packet (1MB, I guess, current value, but be explicit about this), and make it clear what happens if the maximum value is exceeed: I'd suggest send an ERROR message and drop the connection, as otherwise you'd be obliged to try to consume the large message.