[16.0][FIX] queue_job: fix deadlock
Fix a deadlock condition when there are dependent stored fields on queue.job:state.
Example:
- Sale-Order has a stored computed field which depends on job-state.
- A job updates a sale-order record.
- A exception is raised and in the final error-handling with a child cursor in https://github.com/OCA/queue/blob/c93a25366d2c51339ae4530a42eb7393bdc98b12/queue_job/controllers/main.py#L144 the job's state is updated, which also triggers an update in the sale order. Result is a deadlock.
This commit adds a rollback in case of error during job execution, so that any locks are released.
Hi @guewen, some modules you are maintaining are being modified, check this out!
Though I generally agree with the intent of this change, there is already some rollback code in the enclosing
runjobcall, specifically a rollback in the event of aRetryableJobError. It makes me question why theexcept (FailedJobError, Exception)stanza doesn't rollback as well, choosing instead to grab a different cursor to commit the job state.
now I got your comment ^^ Indeed I also don't see the need to use a new cursor if the tx is rolled back. If you agree I change it to just rollback.
There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.