Fetchmail breaks cron transaction policy #585
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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