1

After adding a second block type to an existing matrix field, we started receiving a "General error: 2006 MySQL server has gone away" error when additional content was saved to the new block type (screenshot attached). This error was shown in the CP and on the front-end. I was also unable to export the database via Sequel Pro.

This error only occurred on production- for some reason development and staging were fine.

I have since fixed production by restoring an earlier version of the database. We're now able to add content to the new matrix block type.

In trying to figure out what caused this error, I came upon the max_allowed packet setting.

The MySQL docs say:

Both the client and the server have their own max_allowed_packet variable, so if you want to handle big packets, you must increase this variable both in the client and in the server.

According to this SO post, SHOW VARIABLES LIKE 'max_allowed_packet' tells me that the server value is 64mb.

So I have two questions.

  1. How do I see the current client value of max_allowed_packet (I understand that the docs say it's 16mb by default).
  2. Is it necessary to adjust the client value in the context of running a Craft site? Or does that only apply if I'm manually using the CLI?

enter image description here

3
  • I'm getting same error. I tried all the way which i can do but problem not solved. Have you found any clue to solve this ? Commented Aug 1, 2022 at 4:37
  • @VinodPatidar Sorry, I think I was only able to get past this by restoring a previous database backup :(
    – plaintxt
    Commented Sep 23, 2022 at 15:50
  • Did you find the problem? After migration to craft 5 I experience the same problem
    – KSPR
    Commented Oct 31 at 14:40

2 Answers 2

1

Please try to increase the values for

  • wait_timeout (as Brad pointed out above)
  • net_write_timeout
  • net_read_timeout

Let me know if this helped.

0

max_allowed_packet isn't the only thing that can cause a "MySQL server has gone away" error.

wait_timeout is another common one but, unfortunately, it's a generic error that MySQL throws for many things.

The MySQL docs have a whole page dedicated to those things worth checking out: https://dev.mysql.com/doc/refman/8.0/en/gone-away.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.