In-Portal Issue Tracker - In-Portal CMS
Viewing Issue Advanced Details
316 [In-Portal CMS] Front End bug report always 2009-09-22 15:44 2009-09-23 11:15
active 5.0.0  
0000316: MySQL error "Got a packet bigger than 'max_allowed_packet'" during st_CachedMenu call with 3000 categories
I got MySQL error "Got a packet bigger than 'max_allowed_packet'", when site menu is printed on Front-End via st_CacheMenu tag.

Problem happens because serialized value of "cms_menu" variable in Cache table is larger, then allowed packet size in MySQL and that was 2MB in my case. To solve this I propose to do the following:

1. Add DataType (with index) column to Cache table.
2. Define DataType for each record in table and use it in future when writing data to this table.
3. Instead of writing one "cms_menu" variable we should write a set of variables named "cms_menu_1", "cms_menu_2", "cms_menu_3" and so on with common DataType of "cms_menu".
4. each of "cms_menu_*" variables will contain part of total value of former "cms_menu" variable.

When used, then instead of:
FROM Cache
WHERE VarName = 'cms_menu';

we should use:
SELECT Data, VarName
FROM Cache
WHERE DataType = 'cms_menu';

Then in PHP sort retrieved data by VarName, join them into one string and then unserialize.
Also we could develop central methods for writing/reading to Cache table, that will automatically perform data splitting by multiple variable in case of strings larger, when max_allowed_packet limit is reached.

Because of Cache table is used for storing unit config cache, then moving these methods outside kApplication class will be near to impossible to implement, so they will stay in kApplication class. We could use setCache and getCache and add additional parameter $storage_type (default to memory) to help us.
Issue History
2009-09-23 11:15 alex Note Added: 0000513
2009-09-23 11:15 alex Target Version 5.0.2 => Icebox
2009-09-22 15:44 alex Target Version => 5.0.2
2009-09-22 15:44 alex New Issue

2009-09-23 11:15   
Moving to "Future" because in most of analyzed MySQL servers "max_allowed_packet" is set to "32M" manually, but default value is "1M". Problem only is actual for websites with large amount of data, who will use dedicated hosting anyway.