We're getting this error message on our sites : Notice: unserialize(): Error at offset 0 of 2527853 bytes in _dmemcache_get_pieces() (line 329 of memcache/dmemcache.inc).
Our setup is :
two load balanced servers
one db server
pecl-memcached installed
memcache module installed
cache_consistent installed
site had large views (2.5mb+) where cache has to split values into 3 pieces
We didn't this on our dev servers which had one server for both web & db.
After some investigation, problem seemed to be that the $pieces array in _dmemcache_get_pieces() wasn't in the correct order. e.g. instead of 0,1,2 we have 1,0,2. So when the pieces were put back together, mangled data.
Added a ksort which resolved the issue. Patch attached.
| Comment | File | Size | Author |
|---|---|---|---|
| #23 | memcache-fix_order_pecl_memcache-2415109-7.patch | 655 bytes | Eduardo Alvarez |
| #13 | 2415109-memcache-7.x-1.x-fix-php-warning.patch | 593 bytes | josh waihi |
| #3 | 2415109.patch | 582 bytes | jeremy |
| dmemcache.inc_.patch | 395 bytes | sirnjeet |
Comments
Comment #1
jeremy commentedThanks for the patch, tagging to be sure this is resolved in the next release.
Comment #2
tauseef.gill commentedthank you for the patch, It has resolved the issue on our sites.
Comment #3
jeremy commentedThanks for reporting this. I've attached what should be a more correct patch, letting the PECL extension handle this. Testing would be appreciated.
Comment #4
sirnjeet commentedTested patch, couldn't reproduce error. Thanks!
Comment #5
swaps commented@jeremy : We faced the same issue . We were getting error " unserialize() [function.unserialize]: Error at offset 1048395 of 6028676 bytes in _dmemcache_get_pieces() "
This patch worked like charm !!
Thanks @jeremy.
Comment #6
searchmax commentedBut why does this issue gets encountered? Is it due to large cached data in memcache or due to distributed server setups where there are multiple db servers with load balancers. This issue popped up on its own but unable to figure out on why this issue has popped up?
Thanks in advance for clarification.
Comment #7
swaps commented@searchmax: For my case, environment setup is distributed server setup; but issue occurred when size increased for cached data in memcache.
Comment #8
jeremy commented@searchmax, this can happen when you have multiple memcache servers, and you request an item that was large enough to be split into multiple pieces. This is because Memcached::getMulti doesn't guarantee the order in which the pieces will be returned, unless you set the Memcached::GET_PRESERVE_ORDER flag (which the attached patch fixes). So the answer to your question is "yes, both of those together".
Comment #10
jeremy commentedThanks for everyone who tested. Committed to 7.x-1.x:
http://cgit.drupalcode.org/memcache/commit/?id=3039461
Comment #12
jeremyattime commented@jeremy: I've applied the patch (https://www.drupal.org/files/issues/2415109.patch) successfully, but now seeing a different issue:
PHP Fatal error: Cannot pass parameter 2 by reference in /sites/all/modules/contrib/memcache/dmemcache.inc on line 375
PHP Stack trace:
PHP 1. {main}() /usr/share/pear/drush/drush.php:0
PHP 2. drush_main() /usr/share/pear/drush/drush.php:16
PHP 3. _drush_bootstrap_and_dispatch() /usr/share/pear/drush/drush.php:61
PHP 4. drush_bootstrap_to_phase() /usr/share/pear/drush/drush.php:81
PHP 5. drush_bootstrap() /usr/share/pear/drush/includes/bootstrap.inc:308
PHP 6. _drush_bootstrap_drupal_full() /usr/share/pear/drush/includes/bootstrap.inc:185
PHP 7. drupal_bootstrap() /usr/share/pear/drush/includes/bootstrap.inc:930
PHP 8. _drupal_bootstrap_full() /site/includes/bootstrap.inc:2278
PHP 9. module_invoke_all() /site/includes/common.inc:5215
PHP 10. call_user_func_array() /site/includes/module.inc:895
PHP 11. context_init() /site/includes/module.inc:895
PHP 12. context_get_plugin() /sites/all/modules/contrib/context/context.module:168
PHP 13. context_conditions() /sites/all/modules/contrib/context/context.module:474
PHP 14. _context_registry() /sites/all/modules/contrib/context/context.module:499
PHP 15. context_cache_set() /sites/all/modules/contrib/context/context.module:521
PHP 16. cache_set() /sites/all/modules/contrib/context/context.module:344
PHP 17. MemCacheDrupal->set() /site/includes/cache.inc:136
PHP 18. MemCacheDrupal->wildcardFlushes() /sites/all/modules/contrib/memcache/memcache.inc:188
PHP 19. MemCacheDrupal->wildcards() /sites/all/modules/contrib/memcache/memcache.inc:330
PHP 20. dmemcache_get_multi() /sites/all/modules/contrib/memcache/memcache.inc:378
Drush command terminated abnormally due to an unrecoverable error. [error]
Error: Cannot pass parameter 2 by reference in /sites/all/modules/contrib/memcache/dmemcache.inc, line 375
Comment #13
josh waihi commentedAttached is a simple patch to fix the php warning issue committed to 7.x-1.x
Comment #14
jeremyattime commentedThanks @Josh. The updated patch works on my local. Will continue testing on Dev.
Comment #15
damienmckennaIt seems this needs the follow-on patch?
Comment #16
zuernbernhard commentedYes 2415109-memcache-7.x-1.x-fix-php-warning.patch did the job for me, no other file needed.
Comment #17
zuernbernhard commentedComment #19
jeremy commentedThanks -- fix committed:
http://cgit.drupalcode.org/memcache/commit/?id=243c2f4
Comment #20
jeremy commentedAnd committed to 6.x-1.x also:
http://cgit.drupalcode.org/memcache/commit/?id=6355fe8
Comment #23
Eduardo Alvarez commentedI'm experimenting still this issue when using PECL Memcache library.
I provide patch for fixing the ordering when using the other php memcache library, seems 8.x version already implements similar approach.
Comment #24
Eduardo Alvarez commentedComment #25
jeremy commentedSee http://cgit.drupalcode.org/memcache/commit/?id=6355fe8 -- this is handled by the memcache/memcached extension. It works fine in the latest release with the recommended memcache extension. The not-recommended memcached extension requires latest -dev.
Comment #27
jeremy commentedOuch, I stand corrected! While fixing the tests I realized you were absolutely correct. Thanks for the patch, committed!