The "MySQL has gone away" errors I've seen in the past have been caused by connections being left open, not getting traffic for a period of time, and the server closing the connection without the client knowing. We used to get them all the time on our dev and testing server.
Probably the easiest way to deal with it is to use a wrapper that'll catch the error, reopen the connection, and reissue the query.