From 7303fbcd8735158c6a0c1074c9c1cdbc2f0d3568 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Tue, 11 Apr 2023 18:01:00 +0900 Subject: [PATCH 1/2] Increase default MaxAllowedPacket to 64MiB --- const.go | 2 +- errors.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/const.go b/const.go index b1e6b85ef..64e2bced6 100644 --- a/const.go +++ b/const.go @@ -10,7 +10,7 @@ package mysql const ( defaultAuthPlugin = "mysql_native_password" - defaultMaxAllowedPacket = 4 << 20 // 4 MiB + defaultMaxAllowedPacket = 64 << 20 // 64 MiB. See https://github.com/go-sql-driver/mysql/issues/1355 minProtocolVersion = 10 maxPacketSize = 1<<24 - 1 timeFormat = "2006-01-02 15:04:05.999999" diff --git a/errors.go b/errors.go index 7c037e7d6..ff9a8f088 100644 --- a/errors.go +++ b/errors.go @@ -27,7 +27,7 @@ var ( ErrOldProtocol = errors.New("MySQL server does not support required protocol 41+") ErrPktSync = errors.New("commands out of sync. You can't run this command now") ErrPktSyncMul = errors.New("commands out of sync. Did you run multiple statements at once?") - ErrPktTooLarge = errors.New("packet for query is too large. Try adjusting the 'max_allowed_packet' variable on the server") + ErrPktTooLarge = errors.New("packet for query is too large. Try adjusting the `Config.MaxAllowedPacket`") ErrBusyBuffer = errors.New("busy buffer") // errBadConnNoWrite is used for connection errors where nothing was sent to the database yet. From ae315d6bcb8256dcfb52ef0c6cd9ed58c7eb1e07 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Tue, 11 Apr 2023 18:03:21 +0900 Subject: [PATCH 2/2] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 25de2e5aa..252bbefdf 100644 --- a/README.md +++ b/README.md @@ -282,7 +282,7 @@ Please keep in mind, that param values must be [url.QueryEscape](https://golang. ##### `maxAllowedPacket` ``` Type: decimal number -Default: 4194304 +Default: 64*1024*1024 ``` Max packet size allowed in bytes. The default value is 4 MiB and should be adjusted to match the server settings. `maxAllowedPacket=0` can be used to automatically fetch the `max_allowed_packet` variable from server *on every connection*.