Drupal 7: Dealing with "Additional uncaught exception thrown while handling exception" error

If you see errors like this all of the sudden in your Drupal 7 site and you're trying to figure out if maybe you accidentally moved a file or your cat walked across your keyboard when you were looking at peacocks fighting for a dead snake out the window, it's probably not you. It's your MySQL settings.

You might see the following kind of error:

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: DELETE FROM {cache} WHERE (cid LIKE :db_condition_placeholder_0 ESCAPE '\\') ; Array ( [:db_condition_placeholder_0] => entity\_info:% ) in cache_clear_all() (line 176 of /Chris/Websites/loc.blog.buildamodule.com/includes/cache.inc).

To fix it, change the max_allowed_packet value in your my.cnf file (that's your MySQL configuration file) to 20:

max_allowed_packet = 20M

Thank you to this thread on Drupal.org, which also describes where to find your my.cnf file.

Here's what the mess might look when you see it:

Additional uncaught exception thrown while handling exception. Original pnObeeJMinn: SQtST ATEIHYOlOl: general eme: 2006 MySQL has gone away: DELETE frOM {cacbe} WHERE (CID like :db_coodidon..Jl'laccholder_O ESCAPE Anay l:db_coodjtion?holder_O) mgr. cmil}\.info:tk I in (line 176 of IChri save twit joe blog huild,'nloduk com'i nc III d l'S" C I'm incl. Additional PD o ? cepe ion: SQLSTATEIHYwOl: General enOl: loof, MySQL server has gone away: SELECT fill-flame FROM (registry) WHERE rmrc type: army J: mmol past view ? ? I. type] interface in ? (line 3058 of "hri ? 10.; bl(lg.buiidamudulc ct1rnjinciude.vh4xy4xtrap.in :name AND type Uncaught exception thrown in shutdown function. puObectinn: SQtSTATEIHYOIlOl: general cnm: 2006 MySQL server has gone away: DEuton. FROM {scn"Ollilore) WHERE (vuluc :db ? Array C l:db_condili(Jn_plal.?hotdl'1_OI 4gt.14679880650621 J in lock rete. alto (line 269 of 'Chri brillS joe .b log, bu .com 'l nc It! d l'S' ? .inc i F.l.a! neauant ru()t;?ttpllon with SQL SI VI Eli it 0001 general fir BVM thsillOSP ? .1, it ? build alll( Kl u It co IIllinc III Ilia half Id ala b ? JU on line llJ6 20116 SQL has hone ly PDOfo:xttptlon: SQLST To: llYOOol: Oeneral error: loof, M,SQL server has gone awav in .hlo?,huilctllmodult' comlincludesldalahan data has ANC on nne 2136 Call Stack