From 63be89ba00c9346348ebf8268fc4a96cceec2dd9 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 5 Jul 2012 16:03:58 -0700 Subject: [PATCH] Improve error message for error 2006 Summary: See discussion here: https://secure.phabricator.com/chatlog/channel/%23phabricator/?at=21186 Basically, MySQL usually raises a good error if we exceed "max_allowed_packet": EXCEPTION: (AphrontQueryException) #1153: Got a packet bigger than 'max_allowed_packet' bytes But sometimes it gives us a #2006 instead. This is documented, at least: >"With some clients, you may also get a Lost connection to MySQL server during query error if the communication packet is too large." http://dev.mysql.com/doc/refman//5.5/en/packet-too-large.html Try to improve the error message to point at this as a possible explanation. Test Plan: Faked an error, had it throw, read exception message. See also chatlog. Reviewers: btrahan, skrul Reviewed By: skrul CC: aran Differential Revision: https://secure.phabricator.com/D2923 --- .../connection/mysql/AphrontMySQLDatabaseConnectionBase.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/infrastructure/storage/connection/mysql/AphrontMySQLDatabaseConnectionBase.php b/src/infrastructure/storage/connection/mysql/AphrontMySQLDatabaseConnectionBase.php index 8224592f5f..476e6049a2 100644 --- a/src/infrastructure/storage/connection/mysql/AphrontMySQLDatabaseConnectionBase.php +++ b/src/infrastructure/storage/connection/mysql/AphrontMySQLDatabaseConnectionBase.php @@ -217,8 +217,11 @@ abstract class AphrontMySQLDatabaseConnectionBase switch ($errno) { case 2013: // Connection Dropped - case 2006: // Gone Away throw new AphrontQueryConnectionLostException($exmsg); + case 2006: // Gone Away + $more = "This error may occur if your MySQL 'wait_timeout' ". + "or 'max_allowed_packet' configuration values are set too low."; + throw new AphrontQueryConnectionLostException("{$exmsg}\n\n{$more}"); case 1213: // Deadlock case 1205: // Lock wait timeout exceeded throw new AphrontQueryDeadlockException($exmsg);