Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions queue_job/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,16 @@ def runjob(self, db, job_uuid, **kw):
env = http.request.env(user=odoo.SUPERUSER_ID)

def retry_postpone(job, message, seconds=None):
job.postpone(result=message, seconds=seconds)
job.set_pending(reset_retry=False)
job.store()
env.cr.commit()

job.env.cr.rollback()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't you rollback only in case of errors? /cc @guewen

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's there to prevent a conflict between the job.env's transaction and the new one. The job record might have been updated by the first one and will be updated by the second one? It's not called in the FailedJobError case though so why is it necessary here?

job.env.clear()
with odoo.api.Environment.manage():
with odoo.registry(job.env.cr.dbname).cursor() as new_cr:
job.env = job.env(cr=new_cr)
job.postpone(result=message, seconds=seconds)
job.set_pending(reset_retry=False)
job.store()
new_cr.commit()

job = self._load_job(env, job_uuid)
if job is None:
Expand Down