i've noticed since i started using memcache that when i update the roles for a user, they don't see the new menu items they are entitled to.

if i cache_clear_all the menu cache, suddenly they can.

i suspect that menu.module issues a wildcard cache_clear_all when a user is updated. since memcache can't handle wildcards, we get no love.

memcache probably needs to flush the entire cache_menu bin on a user edit that involves a role change. this is unfortunate, but probably rare in most use cases. i'm not sure how easy/not easy it is to construct a hook that can tell when the role is changing.

CommentFileSizeAuthor
#7 user.module.patch1.06 KBfirebus

Comments

firebus’s picture

user.module
function user_edit_submit
line 1500 or so

cache_clear_all($account->uid .':', 'cache_menu', TRUE);

replace with:

$languages = locale_supported_languages();
foreach (array_keys($languages['name']) as $locale) {
  cache_clear_all($account->uid . ':' . $locale, 'cache_menu');
}

i'll provide a patch after i upgrade to 5.3...

robertdouglass’s picture

Please try putting that code in memcache.module, memcache_user hook ($op == 'update', I think), and see if that takes care of the problem.

Is this a core bug?

firebus’s picture

imo it's a core "by design". i found a similar issue with advcache's path caching, which i'll report separately once i've found the code.

any time core uses a wildcard to clear keys with a specific prefix, memcache isn't going to handle it gracefully and the cache will not be cleared for those keys.

since memcache is patching core for the serialization issues, i don't think it would be too evil to patch core for the wildcard issues, however, it's definitely nicer if we can do it with the hook. op might be save instead of update (i think menu_cache clears the cache in save)

i'll take a look and give you a patch!

firebus’s picture

the solution in http://drupal.org/node/199483 (in case of wildcard, flush the whole bin) works against your proposed solution here.

we have to at least patch menu.inc to disable the wildcard call.

the replacement code can live in menu.inc or in memcache.module, but including it in menu.inc is more readable.

robertdouglass’s picture

@firebus: can you provide an update on this issue and propose a fix?

robertdouglass’s picture

Priority: Normal » Critical
firebus’s picture

StatusFileSize
new1.06 KB

i'm running happily with the above code, but it would be nicer to test if memcache is enabled, and also test if locale is enabled.

since we now clear the whole bin for all cache_clear_all calls with wildcards, this is no longer a bug. however, we definitely save some cycles by computing the correct keys to clear instead of dropping the whole bin.

here's a patch against user.module in 5.8. i'm not sure if it makes sense to roll this into cache-serialize-patches or if you want a different patch file for non-serialization related issues.

perhaps there's been some changes around the wildcard cache_clears issue that supercedes this issue, or would allow for a memcache_user hook fix - let me know. i haven't been keeping up with that issue...

jeremy’s picture

Status: Active » Needs review

Bump. Has anyone tested this?

catch’s picture

Status: Needs review » Closed (won't fix)

Just marked 5.x as unsupported.