I'm currently setting up a Drupal 7 site using Commerce and Rules 2, but I've run into a small bug when using Rule Components. I've defined a pricing rule that uses a rule component that does the actual rule calculation legwork. The pricing rule + the rule component seem to work fine most of the time.

However, frequently after making changes to site structural elements like views, content types, or other rules, I find that the first time I load one of the products affected by the pricing rule, I see a trace of rules evaluation, even though "debug rules evaluation" is turned off. In addition, the price of the product ends up being "$0.00" and inside the trace I see the error message "Unable to get the component [NAME OF COMPONENT]...", where "[NAME OF COMPONENT]" is the name of my rule component. If I refresh the page, however, all is good -- no more trace output, and the price is calculated correctly.

Any thoughts?

Comments

das-peter’s picture

Component: Rules Core » Rules Engine

I suffer from the same / a similar issue and it's very difficult to isolate the trigger since it happens without any structure.

Could you check if your watchdog contains an entry like this:
Rule could not be load from cache!! Component %name Return "%component"

There are two locations where a "Unable to get the component %name" exception is thrown.
One in the rules_scheduler and one in the rules_core.eval.inc. The one in rules_core.eval.inc creates the mentioned watchdog entry.

Since you describe it happens randomly I assume you've such a watchdog entry.
If so, please let me know if you use a special cache engine (e.g. memcache).

As far as I understand the code of rules_get_cache() tries to load the component from the cache but if this fails it rebuilds the component - interestingly it fails totally sometimes nevertheless.

For now the only thing I can imagine of that could break something there is a timing issue.

das-peter’s picture

Just checked the commit log because I'm working on a site update and came across this commit: fixed rules_get_cache() to be reliable and return results even if the cache system always has cache fails.

Looks like this could fix the described errors *yay*

fago’s picture

Status: Active » Fixed

I hope so too. So just re-open if there are still issues.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mr.baileys’s picture

Status: Closed (fixed) » Active

We are running into the same issue where rules occasionally throws an RulesEvaluationException exception with the message "Unable to get the component commerce_coupon_basic_validate_uses_of_coupon_component", followed by "Unable to evaluate action component_commerce_coupon_basic_validate_uses_of_coupon_component.".

We're unable to consistently reproduce this. More often that not everything works as expected, but now and then the exception is thrown. We are running 7.x-2.0 which includes the commit mentioned in #2.

The issues did not occur before we switched on memcache on the site, although I don't know whether or not this is related.

mr.baileys’s picture

Switching back from MemCacheDrupal to the default DrupalDatabaseCache for the rules cache-bin seems to fix the issue on our end, and the Rules exceptions are no longer thrown.

$conf['cache_class_cache_rules'] = 'DrupalDatabaseCache';
das-peter’s picture

Oh nooo, another memcache issue then?! Did you use the latest memcache integration 7.x-1.0 ( 2012-Jan-19)?

mr.baileys’s picture

Yes, we're running Memcache API and Integration 7.x-1.0 (although this is basically the same as 7.x-1.0-rc3)...

ghindle’s picture

Status: Fixed » Active

+1 Subscribing to this bug.

I having the same symtoms as mr.baileys. Rules were working fine until enabling memcache. Just implemented the work around mentioned in #6, hopefully this cures the problem. I'll post back with my findings in a couple of days.

Edit: I can confirm that the work around mentioned in #6 has fixed the problem I was having. Thanks mr.baileys

das-peter’s picture

Please make sure you don't use the PECL memcache version 3.0.4. This version has a bug that causes flushes to fail. (Ubuntu Lucid and Debian 6 are shipped with the broken version!)
More information you'll find on the troubleshooting page of memcache

fago’s picture

#10 might be the source of the problem. Anyway, the suggested improvements over at #1425652: Event is not invoked if the cache does not exist for it. should fix this issue too.

fago’s picture

Status: Active » Fixed

Status: Active » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.