From 557878afe90409aef14202a61fd8d819f24907a1 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 10 Oct 2019 08:41:33 +0200 Subject: [PATCH] [IMP] forwardport: processing queue reliability The queue would get items to process one at a time, process, commit, and go to the next. However this is an issue if one of the item fails systematically for some reason (aka it's not just a transient failure): the cron fails, then restarts at the exact same point, and fails again with the same issue, leading to following items never getting processed. Fix by getting all the queue contents at once, processing them one by one and "skipping" any item which fails (leaving it in place so it can get re-processed later). That way, even if an item causes issues, the rest of the queue gets processed normally. The interruption was an issue following odoo/enterprise#5670 not getting properly updated in the backend (backend didn't get notified of the last two updates / force-push to the PR, so it was trying to forward-port a commit which didn't exist - and failing). --- forwardport/models/forwardport.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/forwardport/models/forwardport.py b/forwardport/models/forwardport.py index 116e615f..b6a7f8b3 100644 --- a/forwardport/models/forwardport.py +++ b/forwardport/models/forwardport.py @@ -14,16 +14,14 @@ class Queue: raise NotImplementedError def _process(self): - while True: - b = self.search([], limit=1) - if not b: - return - - b._process_item() - - b.unlink() - self.env.cr.commit() - + for b in self.search([]): + try: + with self.env.cr.savepoint(): + b._process_item() + b.unlink() + self.env.cr.commit() + except Exception: + _logger.exception("Error while processing %s, skipping", b) class BatchQueue(models.Model, Queue): _name = 'forwardport.batches'