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
Comment #1
das-peter commentedI 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_schedulerand one in therules_core.eval.inc. The one inrules_core.eval.inccreates 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.
Comment #2
das-peter commentedJust 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*
Comment #3
fagoI hope so too. So just re-open if there are still issues.
Comment #5
mr.baileysWe 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.
Comment #6
mr.baileysSwitching 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.
Comment #7
das-peter commentedOh nooo, another memcache issue then?! Did you use the latest memcache integration 7.x-1.0 ( 2012-Jan-19)?
Comment #8
mr.baileysYes, we're running Memcache API and Integration 7.x-1.0 (although this is basically the same as 7.x-1.0-rc3)...
Comment #9
ghindle commented+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
Comment #10
das-peter commentedPlease 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
Comment #11
fago#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.
Comment #12
fagoshould be fixed with http://drupal.org/node/1425652#comment-5719972