Problem with creating node an high rid.

goudal - May 13, 2008 - 15:04
Project:Advanced cache
Version:5.x-1.6
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:duplicate
Description

Hello,

I have had problems while creating a node and advcache activated, php get a timeout and nothing happens exept the timeout message.

After some digging I have found the problem is there in the fonction advcache_nodeapi :

     if (!in_array($node->type, variable_get('advcache_node_exclude_types', array('poll')))) {
        $maxrole = pow(2, (int)db_result(db_query("SELECT MAX(rid) FROM {role}")) - 1);
        for ($i = 1; $i < $maxrole; $i++) {
          cache_clear_all($node->nid. '::'. $i, 'cache_node');
        }
}

My max rid is 26. So the cache_clear_all is called ...well too manytimes.

I have replaced the loop with

cache_clear_all($node->nid.'::','cache_node',TRUE);

It seems to work.

#1

firebus - May 13, 2008 - 18:13

yes, but that breaks support for memcache, which doesn't handle wildcards and is a common use case for advcache users.

there are a couple of ideas in the support queue for handling this:

- it's unclear that we need to cache node by role combo at all (although we do for comments, since we cache lists as well as individual comments)
- we can and should have a switch based on module_exists('memcache') that only does the expensive stuff if memcache is enabled
- we should keep track of actual role combinations in use and only clear those (you have 26 roles, but you probably don't have 2^26 combinations - there are probably ~26 actual role combos in use which is a much less painful cache clear)

my point being that yes, you're doing the right thing for your use case, but it's not a good general fix for the problem...

#2

goudal - May 14, 2008 - 06:56

Some more information on my own case :
- I only have users that belongs to more than one role : we use drupal as an intranet and every user will have at least one role provided by its identification and one other describing its functions (and giving right to publish informations).
- for now I have not 26 roles, but due to history, I have 8 roles with a big gap 1 2 3 4... 20 24 25 26....
But... I have had thought about building roles from our ldap directory, and that can lead to a high number of roles.

On the caching issue, I think that each node won't have a lot of occurences cached : as it's an intranet, lot of nodes will be seen only by the concerned people. I thought that a list of cache id for each node whould have been a solution too. But it would need some more patching.

For our usage advcache is a must, as we have only authenticated user and we need performance.

Anway thanks for the quick answer.

#3

robertDouglass - July 18, 2008 - 21:50
Status:active» duplicate

http://drupal.org/node/199465

 
 

Drupal is a registered trademark of Dries Buytaert.