[12.0][FIX] queue_job: don't enqueue dependent jobs after a retryable postpone (closed cursor)#944
Conversation
|
Hi @guewen, |
|
@guewen could you merge? |
|
/ocabot merge patch |
|
On my way to merge this fine PR! |
|
@guewen it seems you have to force merge it, as the automatic merge don't work in this case. |
@MiquelRForgeFlow ok, I have no computer at hand, could you increase the patch version so I force merge? |
…pone When a job's perform() raised a PG serialization error, the runjob controller wrapped it as RetryableJobError and called retry_postpone(), which reassigns job.env to a temporary cursor inside a `with` block and closes it on exit. The handler then fell through to _enqueue_dependent_jobs() -> Job.enqueue_waiting(), running self.env.cr.execute() on that now-closed cursor and raising "psycopg2.OperationalError: Unable to use a closed cursor". A postponed job is not done and must not release its dependent jobs, so return right after the rollback. This also avoids touching the closed cursor. Aligns 12.0 with the upstream 14.0+ behaviour.
3042c60 to
6d7d228
Compare
Done. |
|
Thanks! |
|
@guewen your merge command was aborted due to failed check(s), which you can inspect on this commit of 12.0-ocabot-merge-pr-944-by-guewen-bump-patch. After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red. |
1 similar comment
|
@guewen your merge command was aborted due to failed check(s), which you can inspect on this commit of 12.0-ocabot-merge-pr-944-by-guewen-bump-patch. After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red. |
Problem
Graph jobs that hit a Postgres serialization/concurrency error crash the
/queue_job/runjobrequest with:Traceback tail:
Root cause
In
RunJobController.runjob, theexcept RetryableJobErrorhandler calls the localretry_postpone(), which does:The handler ended with env.cr.rollback() but no return, so control fell through to self._enqueue_dependent_jobs(env, job) ->
job.enqueue_waiting(), which runs self.env.cr.execute(...) on the closed cursor. This only triggers for jobs in a dependency graph that hit a retryable error, which is why it's intermittent.
Fix
Return right after the rollback in the RetryableJobError branch. A postponed job isn't done, so it must not release its dependents — and this avoids using the closed cursor. This matches upstream OCA queue_job behaviour in 14.0/15.0/16.0.