Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetchmail breaks cron transaction policy #585

Closed
wants to merge 1 commit into from
Closed

Fetchmail breaks cron transaction policy #585

wants to merge 1 commit into from

Conversation

jbq
Copy link
Contributor

@jbq jbq commented Jun 17, 2014

Fetchmail module installs a method to process mail messages from incoming mail servers.

This method is called by ir.cron periodically. ir.cron uses a db locking strategy on cron job record to prevent simoultaneous call by multiple workers threads on the same job.

Fetchmail cron method receives the cursor from cron and reuses it making a cr.commit on each received message, thus breaking the lock policy of to prevent simoultaneous execution. The net effect is that fetchmail is called several times when message collecting from input mail servers takes longer than the interval between cron calls (60 seconds)(a common situation when the server is configured with slow mail services). In my cases this process ends up with stalled cron fetchamail process, and thus NO MAIL WAS COLLECTED unless you manually reset the server

The solution is to use a separate cursor to process incoming messages

See https://bugs.launchpad.net/openobject-addons/+bug/1228421

Fetchmail module installs a method to process mail messages from
incoming mail servers.

This method is called by ir.cron periodically. ir.cron uses a db locking
strategy on cron job record to prevent simoultaneous call by multiple
workers threads on the same job.

Fetchmail cron method receives the cursor from cron and reuses it making
a cr.commit on each received message, thus breaking the lock policy of
to prevent simoultaneous execution. The net effect is that fetchmail is
called several times when message collecting from input mail servers
takes longer than the interval between cron calls (60 seconds)(a common
situation when the server is configured with slow mail services). In my
cases this process ends up with stalled cron fetchamail process, and
thus NO MAIL WAS COLLECTED unless you manually reset the server

The solution is to use a separate cursor to process incoming messages

See https://bugs.launchpad.net/openobject-addons/+bug/1228421
@mart-e
Copy link
Contributor

mart-e commented Jun 17, 2014

Hello,

Have you been able to reproduce that bug ? It seems to me it's not present as we are using two different cursors for locking and running the job.
Check ir_cron.py. We have a lock_cr and a job_cr so it should not be problematic to commit during the cron.

An easy way to prove it is using the applying the following patch. It will commit between each mail fetched by your imap server. Even during the sleep you can not edit your cron (e.g. change the date) and check that only one cron is running (if you set a 1min running frequency). It is still locked.

@mart-e mart-e added the blocked label Jun 17, 2014
@jbq
Copy link
Contributor Author

jbq commented Jul 4, 2014

I can confirm I'm using the same ir_cron.py as in odoo's 7.0 branch. The fetchmail server got stalled twice in a month, causing a downtime in email processing until we notice it and restart the server.

I still have to run with my patch applied in production to confirm if it still happens.

@mart-e mart-e removed the blocked label Jul 4, 2014
@ghost ghost assigned tde-banana-odoo Aug 13, 2014
@ghost ghost added the need review label Aug 13, 2014
@tde-banana-odoo
Copy link
Contributor

Confirming @mart-e thoughts. Are you sure it is due to the cursor ? Note there was some patches recently in the cron, are you using the latest 7.0 sources ?

@mart-e
Copy link
Contributor

mart-e commented Aug 27, 2014

If there were concurrency issues, they were fixed in 7.0 at revision 6788edc (backport of master).
As we use different cron, it should not be related in fetchmail.

@mart-e mart-e closed this Aug 27, 2014
@yelizariev
Copy link
Contributor

I have similar issue #7464
My suggestion is to add timeout for socket connection.

rousseldenis pushed a commit to roussel2nis/odoo that referenced this pull request Jul 19, 2018
[ADD] account_voucher migration. All checks passed. Merging.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants