A number of my rules, which use the event "After updating existing content" refused to trigger until I had cleared the site-cache. Rebuilding the Rules' cache did nothing (admin/config/workflow/rules/settings/advanced). I would appreciate some background on this issue because the cache does not always interfere with event triggering.

Why does the cache interfere with event triggering?
Is there a way to ensure caching does not interfere with event triggering? Outside of completely disabling caching.

CommentFileSizeAuthor
#25 rules.png27.47 KBmarameodesign
#25 cron_rule.png48.17 KBmarameodesign
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kbk’s picture

bump

SilviaT’s picture

Same here.
I have 2 rules: one triggers on "After updating existing content", the other on "After saving new content".
The second one sometimes doesn't trigger unless I clear the site cache.
I didn't manage to figure out yet when it stops triggering.

mitchell’s picture

Status: Active » Postponed (maintainer needs more info)

This is highly unexpected. I have never experienced this trouble over several years using Drupal, and this is the first time I've ever seen it in the Rules issue queue.

Please describe your web stack.

SilviaT’s picture

I think I understood what the problem was in my case.

I had
- 2 active rules
- 1 inactive rule and not working because the actions that it was using were belonging to a disabled module

The 2 active rules weren't triggered at all, unless I flushed the cache for the whole site. After a while they would stop working (no idea why yet).
Then I tried to fix the inactive rule by enabling the module that was required as a dependency to make it work.

After that both the active rules started being triggered again!
My guess then is that if there are some rules that are not valid, even if disabled, they prevent all the rules to be triggered.

SamSteinig’s picture

Has anybody figured this out yet? I have one simple rule on my site ("after saving new content") that sometimes stops triggering, and will only start up again when I clear the site cache. It'll work for a few days, and then stop again. Clearing the site cache always fixes it, but only temporarily.

SamSteinig’s picture

Any ideas? Anybody?

fago’s picture

7.x-2.x has received a slightly re-vamped approach of caching rules for execution. Could you test whether things are different with the latest dev version?

SamSteinig’s picture

Just installed. Works OK so far. Won't know until a day or so if it stops (that's been the pattern). I'll keep you posted.

SamSteinig’s picture

Still experiencing the same issue :(

The rule stopped firing, and wouldn't work again until I cleared the site cache.

SamSteinig’s picture

Any ideas, fago?

fago’s picture

I guess you have some sort of cache rebuilding issues where sometimes caches are rebuilt with incomplete information.

maxplus’s picture

I have the same issue. After a while some of my Rules are not firing anymore until I clear caches... pretty annoying. I am using the latest Rules 7.x-2.6

maxplus’s picture

I'm trying to avoid the event "after updating existing content" and replace it by "before saving content of type xx".
As condition I add "Entity is not new".

This is a test to see if my rules keep running now without having the need to clear the cache sometimes.

maxplus’s picture

Issue summary: View changes

Hi,

I'm still facing this issue...

This is the situation after some investigation:

1. The rules with these events fire always without clearing the site's cache:
- "After saving new content of type xx"
- "Content is viewed"

2. The rules with these events fire for a while after clearing the the site's cache and then suddenly the don't fire anymore until I clear caches again:
- "After updating existing content"
- "Before saving content"

After they stopped firing, I did the following tests:

- Created a new rule with the event "After updating existing content" with just one action "Show a message on the site" to see if that new rule would fire
=> it also does not fire

- I have changed the weight of the rules that don't fire to -10, to see if that had any influence
=> it does not make any difference

- I have enabled rules debugging and logging
=> there is nothing reported or logged for the rules with the events "After updating existing content" and "Before saving content"

- I did the Integrity check again and Rebuild the Rules cache
=> after that, the rules still not fire

- I disabled all kinds of related modules like:
* Rules Forms Support
* Rules translation
* Rules Bonus: Miscellaneous
* Rules developer comments
* Rules Link

* Commerce Rules Extra
* Commerce simple stock rules
* Logintoboggan rules integration
* Rules Array Create
* Rules bonus: block
* Rules bonus: theme
=> I had to enable the first 5 again because I really needed them, I left the last 6 disabled and until now without clearing the site cache again, my rules are firing again

I will evaluate this now and maybe one of the last 6 contributed rules modules is the cause of the problem...

marameodesign’s picture

Hi,

I am having the same problem with "After saving new content of type".

@maxplus do you have any updates?

Thanks

maxplus’s picture

Hi marmameodesign,

I'm still facing this issue, even after disabling several contributed Rules modules.
Now I'm working on a solution that does not use a rule as temporary fix...

maxplus’s picture

Hi,

here is an update about my issue:

I examined the error logs a little bit better, and I have noticed that I had several errors and warnings from my Rules debug log in certain situations.

The warnings are:
- Unable to get the data value for the variable or parameter id. Error: Unable to get the data property product_id as the parent data structure is not set.
- Unable to evaluate action entity_fetch.
- Unable to evaluate action data_set.

The error is:
- Unable to get variable product, it is not defined.

So now I first solved the problem that was generating this error and warnings and now I'm curious if my Rules will still stop working after a while.

=> Maybe because of my "bad programming" the Rules just stop working after a while of to much errors and warnings...

marameodesign’s picture

@maxplus - I checked my logs and I do not have any warnings or errors - but still after a while
the rule just doesn't fire anymore.

There is not even a log event - like it doesn't exist.

It happens only on the rules for "After saving new content of type xx" "After updating existing content" "Before saving content"

This is quite critical, and any help or pointers on this would be appreciated.

Cheers,

maxplus’s picture

Hi marameodesign,

Now I have no errors anymore and today my rule stopped triggering.
So indeed, these errors where not the cause.

Now I have noticed that the time that the Rule stopped working was right after a Cron run. Maybe Cron does something wrong?
=> I have set my Cron jobs to Daily now instead of default every 3 hours, lets see what happens now

Max

marameodesign’s picture

Nice hint.

I will do the same on my environment and report back.

EDIT:
I have cleared the cache and the emails were firing again.
Then I run cron manually - but after a manual cron run they are still working :-(

I am leaving the cron at 12hours - but in the meantime investigating an automatic clear cache solution as a temporary patch until this get solved.

maxplus’s picture

Hi,

I can confirm that Cron has nothing to do with it.
Today my Rule "before saving content" did not run and Cron did not run before,

so looking for another cause.

How are you going to clear cache automatic?

illuminatico’s picture

I was having this same issue, upgraded Entity https://drupal.org/project/entity. Working again.

maxplus’s picture

OK Thanks,

upgraded Entity form 7.x-1.2 to 7.x-1.5.

Lets see what happens now

maxplus’s picture

Hi,

I'm very sad to see that still after replacing the Entity module and changing all my rules conditions to "after updating..." and "after creating a new ...." I still have a moment when these Rules just stop launching until I clear the sites cache...

Getting desperate here

marameodesign’s picture

FileSize
48.17 KB
27.47 KB

Hi maxplus

I have updated the Entity module and also downloaded cache_actions.

I've created 2 rules:

1. Clear cache on cron run (cron run every hour)

2. Clear cache just before sending the html email after saving the node.

I am aware that both solutions are not best practice and WILL slow down the site, but I just need to get something in place to get it to work until is fixed properly.
I will report on how it is going. Any help from developers is vey very appreciated.

Thanks.

Sarenc’s picture

I have this issue as well and can report one different aspect. This occurs on our production environment which is under good load and is using the query cache in mysql. I've never seen it occur on our test server even when replicating the cache settings. Of course it's pretty hard to simulate a caching scenario in non-production environments so I'm not sure what this really says. We were also using APC cache and didn't notice any difference whether it was enabled or not.

The rules were tried on various node triggers with no difference. There was also a flagging trigger so I don't think the problem is with specific events. The actions involved either emails or cache clearing with cache_actions.

I'm pretty good at tracking down errors but stuff like this that can't be reproduced is a killer. I'd say there is a good chance it isn't even with the rules module. For the very few of us affected it probably best to move your "rules" to a custom module and break out the hooks.

maxplus’s picture

Hi Sarenc,

thanks for your contribution to this "lonely" thread.

I can tell that I have these event trigger problems in our test environment where no caching systems are active (no APC, no Varnish, nothing,...).
Also no default Drupal caching is enabled.

bob.hinrichs’s picture

This is because there is a call to [entity]_save, such as user_save, node_save, etc. (or a function that calls [entity]_save) located in a hook_init. The reason for this is obscure, but it is due to the fact that the rules module invokes hook_init, and if another module calls [entity]_save in hook_init that is pulled into the system in order before rules is called, the save event is marked as already fired, and the trigger is not thrown.

The solution in most cases is likely to move the code in your module in hook_init, into hook_page_build or one of those page_ hooks.

see also: https://drupal.org/node/2171153

Sarenc’s picture

I wish that was the case Bob! If you read the messages here though you will see the issue is that rules *stop* firing. The issue you refer is totally different in that it involves a reproducible event - either rules fire or they don't. In my case every single rule fires properly for about an hour and then stops until I clear the caches again.

marameodesign’s picture

Hi All,

Just FYI I ended up making my own custom module to replicate the rule.

baddysonja’s picture

I am having the same problem. I have two rules running, one with "content is viewed" (weight: 10) and another with "After updating existing content." (weight: 0). Both should react on the same content type.

Both will be fired if the cache is cleared - if I then save the node again, only "content is viewed" is fired and not the other one.
Then I clear the cache, and both rules work again.

It would be great if somebody could help out here, maybe give some hints of where to start debugging?

jkopel’s picture

I recently ran into this same issue.
After some quality time with xdebug, I think that bob.hinrichs is correct in #28, and the problem is the same as reported here:https://drupal.org/node/2171153

Much like everyone else in this issue it seemed like the problem was random or time based, but as a result of the info in https://drupal.org/node/2171153 I was able to find a reproducible train of events that would ALWAYS cause rules to stop triggering on the "After updating existing content." event.
The nature of this bug makes it very hard to track down, but that patch in that issue has fixed it for me (so far).

maxplus’s picture

Hi,

I just upgraded to Rules 7.x-2.7 where the patch of https://drupal.org/node/2171153 is included.
Until now, it seems to keep working for me

Sarenc’s picture

Well sorry Bob I didn't believe it at first but three days after trying the patch my events are still firing.

I've already put into code all my needed rules but it's still nice to be able to use this module finally!

Sarenc’s picture

Well this is a bit strange... After leaving some test rules in there a few days and confirming they continue to fire, I disabled them all. A day later I'm still seeing the rules fire as if they're caught in the cache. I've just cleared the cache now and will see if they continue.

UPDATE: After clearing the cache some of the rules continued firing for a couple more days. Any clues on why something like this could happen and whether or not it is related to this larger issue? Perhaps aggressive MySQL query caching?

jelo’s picture

Hi all,

Today I encountered exactly this issue with rules on trigger "Before saving content ...". The rules would simply stop entirely after some time, no log entries or anything. Cache clearing fixed it. I am still on Rules 7.x-2.6 and will update tonight to see if that makes a difference.

Thanks to everyone who investigated this. I was at a loss here for the past 2 hours...

J.

baddysonja’s picture

Hi all,
I have been having the same problem. I have about 10 rules and all that have the event: "After updating existing content" do not work anymore. If I clear the cache, the rules work once but than not more.

It would be very appreciated, if somebody has a solution for this problem.

Sarenc’s picture

Component: Documentation » Rules Core
Category: Support request » Bug report
Status: Postponed (maintainer needs more info) » Fixed

baddysonja,

The solution is posted a few comments up. Follow the link in #33.

Status: Fixed » Closed (fixed)

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