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: 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.