Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ErrPktTooLarge message may be incorrect #1355

Closed
sjmudd opened this issue Sep 27, 2022 · 7 comments · Fixed by #1411
Closed

ErrPktTooLarge message may be incorrect #1355

sjmudd opened this issue Sep 27, 2022 · 7 comments · Fixed by #1411

Comments

@sjmudd
Copy link
Contributor

sjmudd commented Sep 27, 2022

Issue description

See: https://jira.percona.com/browse/DISTMYSQL-226 for context.

An application, orchestrator, using the go-mysql-driver is reporting an error ErrPktTooLarge. The error message states "packet for query is too large. Try adjusting the 'max_allowed_packet' variable on the server" which I think may be incorrect or misleading.

The application does not set maxAllowedPacket explicitly via the DSN in the go driver, so I assume that the default value is being used: https://github.com/zendesk/go-sql-driver-mysql/blob/master/const.go#L13 which is 4 MB.

The MySQL server has a configuration setting of max_allowed_packet = 64MB.

Error log

Not really applicable but for context:

2022-09-26T11:53:51.837501+02:00 orchestratorapp.example.com orchestrator[11887]: 2022-09-26 11:53:51 ERROR flushInstanceWriteBuffer: 2022-09-26 11:53:51 ERROR flushInstanceWriteBuffer last_seen: packet for query is too large. Try adjusting the 'max_allowed_packet' variable on the server
2022-09-26T11:53:51.837569+02:00 orchestratorapp.example.com orchestrator[11887]: packet for query is too large. Try adjusting the 'max_allowed_packet' variable on the server
2022-09-26T11:53:51.837645+02:00 orchestratorapp.example.com orchestrator[11887]: flushInstanceWriteBuffer: 2022-09-26 11:53:51 ERROR flushInstanceWriteBuffer last_seen: packet for query is too large. Try adjusting the 'max_allowed_packet' variable on the server

Configuration

Driver version (or git SHA):

1.6 (part of orchestrator's vendor tree)

Go version: run go version in your console

not 100% sure but "recent".

Server version: E.g. MySQL 5.6, MariaDB 10.0.20

  • MySQL 8.0.30

Server OS: E.g. Debian 8.1 (Jessie), Windows 10

  • Linux / CentOS 8

Expected behaviour

In this case I expect the error is that the application has not set a large enough maxAllowedPacket value, the application is trying to send a SQL statement which is too large and the driver is correctly reporting an error.

However, the error message is wrong: the problem here is that the default setting used by the client is too small, the server side setting is probably fine.

The error should be:

ErrPktTooLarge = errors.New("packet for query is too large. Try setting or increasing 'maxAllowedPacket' in the DSN or adjusting the 'max_allowed_packet' variable on the server")

e.g. This is a trivial change to the constant message that is being given.

I can provide a trivial PR for this if needed, but want to see if you agree that the current error message may incorrectly indicate the actual action to take.

@methane
Copy link
Member

methane commented Sep 28, 2022

You are right. The error message is misleading.
On the other hand, I worried about length of error message.

And I don't want to recommend to use DSN. We need to move much documentations from DSN readme to Config object.

@methane
Copy link
Member

methane commented Sep 28, 2022

And current default value (4MiB) is too small. MySQL uses 16MiB by default.
https://dev.mysql.com/doc/refman/8.0/en/packet-too-large.html

@sjmudd
Copy link
Contributor Author

sjmudd commented Sep 28, 2022

Hi @methane. Thanks for confirming what I suspected.

I've seen various references to the Config object and agree it's cleaner to use that but a lot of code uses Open(dsn string) to open a connection which seems to match the calling interface from database/sql, so to me at least it's not clear how to go from Config to the dsn, and if the MySQL driver accepts Open(dsn string) that seems to be the only place you can suggest to the caller to make changes (for this specific case).

@sjmudd
Copy link
Contributor Author

sjmudd commented Sep 28, 2022

Actually looking here the 8.0 default seems to be 64MB.
https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_max_allowed_packet.

Either way it's larger than the previous 5.7 default value.

@dolmen
Copy link
Contributor

dolmen commented Nov 10, 2022

Here is the way to get the value used for your connection:

SELECT @@max_allowed_packet;

@sjmudd
Copy link
Contributor Author

sjmudd commented Apr 10, 2023

I see no movement on this issue. Can it be resolved? I think it is at least confusing if the mysql driver reports an error which is what the server reports but is triggered by the client configuration setting being wrong. Perhaps provide in the error message the golang client setting of max_allowed_packet that's being used which will give context to the person who sees the error which value was configured on the client.

The server's setting may need to be adjusted but if the client configuration setting is not adjusted then it won't make any difference. So improving the error message would be useful.

@sjmudd
Copy link
Contributor Author

sjmudd commented Apr 14, 2023

Thanks very much for making the change!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants