queue icon indicating copy to clipboard operation
queue copied to clipboard

[16.0][FIX] queue_job: fix deadlock

Open BT-sschmid opened this issue 1 year ago • 2 comments

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.

BT-sschmid avatar Jul 12 '24 07:07 BT-sschmid

Hi @guewen, some modules you are maintaining are being modified, check this out!

OCA-git-bot avatar Jul 12 '24 07:07 OCA-git-bot

Though I generally agree with the intent of this change, there is already some rollback code in the enclosing runjob call, specifically a rollback in the event of a RetryableJobError. It makes me question why the except (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.

BT-sschmid avatar Aug 14 '24 18:08 BT-sschmid

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.

github-actions[bot] avatar Dec 15 '24 12:12 github-actions[bot]