MySql Question...


Unfortunately a query of 924,657 bytes is too big for the current MySQL max_allowed_packet setting of 1,048,576 bytes [INSERT INTO cms_cache (cached_for, dependencies, lang, identifier, the_theme, staff_status, the_member, groups, is_bot, timezone, the_value, date_and_time) VALUES ('main_members', 'cns_member_directory:critical_error:global:chat:cns:search:mail:points:galleries:cns_special_cpf!ajax:ajax_people_lists…]
I thought this was just a matter of editing /etc/my.cnf
I edited the file, rebooted my server but I am still getting the error…. Are there multiple locations for this file?


How to find out the location of currently used MySQL configuration file in linux - Stack Overflow
Also sometimes MySQL options are passed directly into PHP by e.g. /etc/init.d/mysql, although I very much doubt this is the cause in this case.
Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon
- If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
- If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
- If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
- If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.


[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
wait_timeout = 31536000
max_allowed_packet=16M
service mysqld stop
service mysqld start
However, I am still getting the following error… Not sure if it is critical or not? (When looking at the Members List)
Unfortunately a query of 916,905 bytes is too big for the current MySQL max_allowed_packet setting of 1,048,576 bytes [INSERT INTO cms_cache (cached_for, dependencies, lang, identifier, the_theme, staff_status, the_member, groups, is_bot, timezone, the_value, date_and_time) VALUES ('main_members', 'cns_member_directory:critical_error:global:cns:search:galleries:points:cns_special_cpf!ajax:ajax_people_lists!cns_membe…]


This MySQL manual page implies maybe actually what I said about a startup parameter could be true:
https://dev.mysql.com/doc/refman/5.7/en/packet-too-large.html
I just checked the code and we set it explicitly in our code too.
sources/database/mysqli.php:
Code
@mysqli_query($db, 'SET max_allowed_packet=104857600');
What happens if you change this line to:
Code
@mysqli_query($db, 'SET @@global.max_allowed_packet=104857600');
(based on what I saw in 2nd highest voted comment on php - how to check and set max_allowed_packet mysql variable - Stack Overflow)
Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon
- If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
- If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
- If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
- If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.


mysql - Can you increase max_allowed_packet from the client? - Stack Overflow
Definitely check for MySQL startup parameters. I think if you do ps -Af | grep mysqld you'll see the startup params for MySQL.
Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon
- If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
- If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
- If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
- If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.


[root@basslinecartel database]# ps -Af | grep mysqld
root 4563 1 0 12:45 pts/0 00:00:00 /bin/sh /usr/bin/mysqld_safe –datadir=/var/lib/mysql –socket=/var/lib/mysql/mysql.sock –pid-file=/var/run/mysqld/mysqld.pid –basedir=/usr –user=mysql
mysql 4806 4563 0 12:45 pts/0 00:00:00 /usr/libexec/mysqld –basedir=/usr –datadir=/var/lib/mysql –plugin-dir=/usr/lib64/mysql/plugin –user=mysql –log-error=/var/log/mysqld.log –pid-file=/var/run/mysqld/mysqld.pid –socket=/var/lib/mysql/mysql.sock
I'm going to continue fiddling with this and I will let you know if I find a fix / solution!


Ultimately we may be updating the hosting requirements tutorial, so in any event I'd like to find out what is causing this.
Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon
- If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
- If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
- If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
- If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.


I've learned a lot looking at this. MySQL's documentation is very poor, so in the 2nd part of my reply I'm posting some new documentation I've written, which will go into the hosting requirements tutorial.
I'll also address the specific situation here with some context, so anyone else reading this topic can follow with definitive answers.
The code in Composr to set the limit didn't work, which I was not aware of (I'll remove it). So this did need setting at a server level. Usually a webhost will do this for you, but you're either on a VPS or a dedicated, so it has fallen to you. Sorry I didn't realise this setting needed to be done!
My mysqli.php change did actually work. It only worked because you're running your site under the root MySQL user (you only have one site on the server, so that's safe enough).
That said I've reverted the mysqli.php change because your my.cnf also did work.
I'm not sure why your testing indicated this wasn't working, so there must have been some confusion somewhere.
Configuring MySQL (advanced)
Server variables may be set in the MySQL config – either the main config file (e.g. /etc/my.cnf), or included files (e.g. from /etc/my.cnf.d) – or in the startup parameters – or via setting the server variable at run-time. If they are not set anywhere then MySQL will use hard-coded defaults.To find which config file(s) MySQL uses, run this command (Linux and MacOS):
Code (Bash)
In the config file it will look something like this (example for setting max_allowed_packet, which is probably what you want):
Code (Bash)
...
max_allowed_packet = 16M
...
To find if a setting is set in startup parameters (Linux and MacOS) run:
Code (Bash)
If you are changing a config file, or a startup parameter, you naturally need to reset MySQL for it to take effect, e.g. with:
Code (Bash)
Code (Bash)
When a MySQL session is started, certain server variables are cloned into the session (e.g. max_allowed_packet). These variables may then be read and written as either server or session variables (actually max_allowed_packet is read-only as a session variable – an exception described further below). If you set a global variable then the current session is not affected, but new sessions will be. Sessions are thrown out when connections are closed, e.g. when a Composr page is fully served.
To find the values of a variable you can use these MySQL queries (example for max_allowed_packet):
There are lots of equivalent terms and syntaxes in MySQL which can make it confusing when trying to understand the documentation and third party solutions. Here is a guide:
- Types of variable:
- "Server" = "Global"
- "Session" = "Local" = "Connection"
- Commands for setting variables:
- Server variables, all equivalent:
- SET @@global.whatever=something
- SET GLOBAL whatever=something
- Session variables, all equivalent:
- SET whatever=something
- SET @@whatever=something
- SET @@session.whatever=something
- SET SESSION whatever=something
- SET @@local.whatever=something
- SET LOCAL whatever=something
- Server variables, all equivalent:
- Getting variables:
- SHOW VARIABLES = SHOW LOCAL VARIABLES = SHOW SESSION VARIABLES
- (SHOW GLOBAL VARIABLES has no equivalencies [SHOW SERVER VARIABLES doesn't exist – which is inconsistent])
The rest of this section will deal with the specifics of the max_allowed_packet setting, which is the only variable that a server administrator usually needs to set.
max_allowed_packet exists as separate server-side and client-side settings; this is totally different from the concept of server and session variables (which are both server-side) and should not be confused.
max_allowed_packet defaults to 1MB server-side if not configured at all (i.e. this is the hard-coded default). Most web hosts will have a higher default value and Composr defines a minimum requirement of 16MB (Tempcode for dense blocks such as main_members may use a couple of MB, but we define an even higher limit in case of producing very long Comcode pages).
max_allowed_packet's session variable exists but is read-only. Attempts to change it will give an error message. You therefore must configure the server variable correctly.
Only MySQL users with the SUPER privilege may set the server variable. Typically only the root user has this.
max_allowed_packet defaults to 1GB client-side (e.g. PHP), except in official client applications like mysql (16MB) and mysqldump (24MB) (which may be configured in the MySQL configuration, the client configuration sections).
Therefore for the Composr application the client-side setting is irrelevant, but you may come up with it when doing MySQL dumps for example.
max_allowed_packet can be set with "M" syntax, not just with exact bytes. So you can set it to 16M or 16777216, that's your choice. Once parsed MySQL will show it in bytes.
The absolute maximum max_allowed_packet setting (both server-side and client-side, as it relates to the protocol implementation) is 1GB.
Last edit: by Chris Graham
Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon
- If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
- If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
- If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
- If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.


Thanks Chris have a great day.
Last edit: by HardTrancid



Is it possible something else is changing the setting around after MySQL starts I wonder?
Regardless, I've taken a different approach - I've just optimised the member directory to use less cache data.
I've made that change on your site and it will be in the next patch release also.
The problem could still happen in some other places, especially if you have large pages, but that's the only default case I know of.
Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon
- If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
- If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
- If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
- If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.