PDO statement::execute(): MySQL server has gone away

Just in case you have same issue when you deal with big data in Laravel, and try to save the big data into database, you may have same issue.

Original I thought it was time out caused MySQL connection lost, after a couple of round test, I found it’s not because connection lost. (You can use mysql_ping() to test connectivity). The reason is because the data is too big which is out of max_allowed_packet = 2M. Then I changed it to 5M, and now I got another issue:

sqlstate[42000]: syntax error or access violation: 1118 the size of blob/text data inserted in one transaction is greater than 10% of redo log size. increase the redo log size using innodb_log_file_size.

This is because we are using innodb engine, which saved transactions into log file in case you want to rollback the last operation. So the old value of innodb_log_file_size is 5MiB, then I changed to 20MiB, then restart MySQL DB server, the issue is gone.

It’s very interesting that we all thought the server gone away is because connectivity issue, but it’s because we don’t have enough memory of file size settings.

Advertisements

About qianggan

Sr. Software Engineer
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s