Action Rules don't work right after server is started

Bug #944197 reported by Daniel Reis
38
This bug affects 5 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Medium
OpenERP R&D Addons Team 1
Odoo Server (MOVED TO GITHUB)
Fix Released
Undecided
Unassigned
OpenERP Community Backports (Addons)
Fix Released
Medium
Yann Papouin
6.1
Fix Released
Undecided
Unassigned
OpenERP Community Backports (Server)
Fix Released
Medium
Yann Papouin
6.1
Fix Released
Undecided
Unassigned

Bug Description

Automated Actions that are run on write will only run after the scheduled "Check actions" runs for the first time.

To repeat:
- Create an automated action, with no conditions (it will fire on every save)
- Save and test it: it will run correctly.
- Restart the server and test it again immediatly after it's available: nothhing will happen (!)
- Wait until the scheduler runs "Check Action Rules" and then test again: now it will work correctly.

Related branches

Revision history for this message
Amit Parik (amit-parik) wrote :

Hello Daniel,

I have faced the same problem at my end.
First time the Automated Action runs correctly as per your scenario (at the creation time) , when I am restart the server then Automated Action doesn't runs perfectly It will run when the action is called.

I have attached the video for this which will describe the problem reported on lp:943410 and the video is also showing also this problem.

Thanks

Revision history for this message
Amit Parik (amit-parik) wrote :
Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 1 (openerp-dev-addons1)
importance: Undecided → Medium
status: New → Confirmed
Changed in openobject-addons:
status: Confirmed → In Progress
Revision history for this message
Turkesh Patel (openERP) (turkesh-tinyerp) wrote :

Hello,

It has been Fixed in https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-944197-tpa

revision-id: <email address hidden>

revno: 6734

It will be available in trunk soon.

Changed in openobject-addons:
status: In Progress → Fix Committed
Revision history for this message
Daniel Reis (dreis-pt) wrote :

I'm sorry, but I don't how this fix will solve the issue.
The root of the problem is that the register hooks is done only when the scheduler runs the automated actions for the first time.

Changed in openobject-addons:
status: Fix Committed → Confirmed
Revision history for this message
Paul Catinean (wiz-keed) wrote :

Why isn't this branch merged into the stable version?

Revision history for this message
Daniel Reis (dreis-pt) wrote :

The above branch doesn't fix the issue.
The problem is that Rules are only "registered" the first time the the scheduler action runs, which by 6.1 defaults happens at 1 hour intervals.
A workaround might be to reduce interval for the "Check Action Rules" scheduled action (say, every 5mn).
The solution should be the server to register the action rules as soon as it finishes loading modules.

The closes thing I came up is implemented a workaround as part a Action Rule Triggers module: http://apps.openerp.com/addon/7738.
In base_action_rule.py, the users.login() is extended to force Rules be registered as soon as a user logins:

#Force register hooks on user Login, to not depend on scheduler
#BUG https://bugs.launchpad.net/openobject-addons/+bug/944197
class users(osv.osv):
    _inherit = "res.users"

    def login(self, db, login, password):
        #Perform login
        user_id = super(users, self).login(db, login, password)
        #Register hooks
        cr = pooler.get_db(db).cursor()
        rule_pool = pooler.get_pool(db).get('base.action.rule')
        rule_ids = rule_pool.search(cr, 1, [])
        rule_pool._register_hook(cr, 1, rule_ids)
        rule_ids = None
        cr.close()
        #End
        return user_id
users()

Revision history for this message
Paul Catinean (wiz-keed) wrote :

Thank you for you efforts Daniel Reis it's a good workaround, but could someone please have the hook trigger at server startup?

Revision history for this message
Paul Catinean (wiz-keed) wrote :

Is it just me or is this problem suffering from a high dose of neglection? It's a pretty sever problem that will impair the entire business logic and halt all activity beyond the point of automated actions, I.E: Helpdesks will no longer function, crm recrution and whatnot will also come to a full stop and much more

I really doubt server restart (for upgrading purposes, power-outs etc) are that rare that this problem can be ignored as of small-medium importance, is there any way to speed up the process of fixing this nasty out-of-the-box bug?

Revision history for this message
Daniel Reis (dreis-pt) wrote : RE: [Bug 944197] Re: Action Rules don't work right after server is started

I'm pretty sure this issue is at the bottom of the list:

For actions based on time intervals, ran by the cron job, there is no issue.
The problem is for actions running on create/write.
I suspect that in practice these are not used a lot, maybe because they are very limited in what they can do.

To get OpenERP attention it needs to be reported by a Partner or an OPW customer.
Remember that Community Edition is unsupported.

But I think that for this scenario, my login fix provides an effective workaround.
Have you tried it?

Regards
DR

> Date: Wed, 22 Aug 2012 15:22:16 +0000
> From: <email address hidden>
> To: <email address hidden>
> Subject: [Bug 944197] Re: Action Rules don't work right after server is started
>
> Is it just me or is this problem suffering from a high dose of
> neglection? It's a pretty sever problem that will impair the entire
> business logic and halt all activity beyond the point of automated
> actions, I.E: Helpdesks will no longer function, crm recrution and
> whatnot will also come to a full stop and much more
>
> I really doubt server restart (for upgrading purposes, power-outs etc)
> are that rare that this problem can be ignored as of small-medium
> importance, is there any way to speed up the process of fixing this
> nasty out-of-the-box bug?
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/944197
>
> Title:
> Action Rules don't work right after server is started
>
> Status in OpenERP Addons (modules):
> Confirmed
>
> Bug description:
> Automated Actions that are run on write will only run after the
> scheduled "Check actions" runs for the first time.
>
> To repeat:
> - Create an automated action, with no conditions (it will fire on every save)
> - Save and test it: it will run correctly.
> - Restart the server and test it again immediatly after it's available: nothhing will happen (!)
> - Wait until the scheduler runs "Check Action Rules" and then test again: now it will work correctly.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/openobject-addons/+bug/944197/+subscriptions

Revision history for this message
Paul Catinean (wiz-keed) wrote :

You are right Daniel Reis it is just for create/write cases allthough paradoxally another database version of the same server had automated actions trigger on server restart by i haven't changed anything.

I'm pretty sure i tried your fix before and i did work only after i manually loged in each time but can't remember for certain

Your fix only works if a user logs in, can't we bind it to the server startup or run the cron just after module load?

Thanks!

Revision history for this message
Stephane Wirtel (OpenERP) (stephane-openerp) wrote :

I'm really sorry but this bug is not at the bottom of the list. I think the login is not the right method, because If you send a command to the server without the login, the base.action.rule won't be loaded by the system. the best way, in the cron or in the rpc layer before the loading of the database(s).

Revision history for this message
Arnaud Pineux (OpenERP) (api-openerp) wrote :

I everybody,

This bug is now fixed but is waiting for a review. To resolve this issues we add a step after the loading of the database which execute the _register_hook method on every installed model. The _register_hook method belongs now to every openERP model. In addition to resolving this problem, we changed the way to define action_rule's conditions.
Define a action rule condition can be done with a precondition filter and postcondition filter in addition to the condition on timing.
This fix and improvement will be soon released.

Good luck,

Arnaud Pineux

Changed in openobject-addons:
status: Confirmed → Fix Committed
Changed in openobject-addons:
status: Fix Committed → Fix Released
Revision history for this message
Paul Catinean (wiz-keed) wrote :

Was it released in the 7.0 version Raphael Collet?

Changed in openobject-server:
status: New → Fix Released
Changed in ocb-server:
assignee: nobody → Yann Papouin (yann-papouin)
Changed in ocb-addons:
assignee: nobody → Yann Papouin (yann-papouin)
Changed in ocb-addons:
importance: Undecided → Medium
Changed in ocb-server:
importance: Undecided → Medium
status: New → Fix Committed
Changed in ocb-addons:
status: New → Fix Committed
Changed in ocb-addons:
status: Fix Committed → Fix Released
Changed in ocb-server:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.