PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 2006 MySQL server has gone away'
I have a long running php script that I've written to convert my old database into a new format. It has about 2600 records to iterate over, each one executing 2 or 3 mysql statements. It fails on the same record every single time, yet the statement couldn't be simpler:
SELECT `dimensions` FROM `db1`.`games` WHERE `id`='2390'
When I run this statement on its own it works as expected (unsurprisingly), however, it seems that after executing 2389*3 statements before hand in quick succession over a period of 60 seconds, this is the straw that breaks the camel's back.
I did some testing and found if I skip the first 2200 records, it still runs into the same error on '2390', however if I skip the first 2300, it manages to complete the task without an error.
As most articles seem to suggest, I increased my 'max-allowed-packet' from 1M to 16M, but it hasn't helped. The time it takes doesn't seem to have an effect either. I put a sleep(1) after each statement and let it run. After 30 minutes it was still going and working just fine. On record 2390 it failed.
Please help me diagnose this unusual problem, Thank you.