Mysql – max allowed packet keep changing

MySQL

I have a very strange case in mysql 5.5.46. the max_allowed_packet keeps resetting to 1024

show variables like 'max_allowed_packet';
+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| max_allowed_packet | 1024  |
+--------------------+-------+

although it is set in my.cnf to 32M

[mysqld]
max_allowed_packet=32M

and even if i try to run set global max_allowed_packet=33554432; it shows success but does nothing

mysql> set global max_allowed_packet=33554432;
Query OK, 0 rows affected (0.00 sec)

mysql> show variables like 'max_allowed_packet';
+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| max_allowed_packet | 1024  |
+--------------------+-------+
1 row in set (0.00 sec)

when i restart mysql it becomes 32M for a day or two then it back to 1024!! what could be the reason?

Best Answer

Sounds like some code somewhere is performing SET @@max_allowed_packet=1024;.

You could turn on the "general log" to find out where it is coming from.