Repository navigation
[16.0][IMP] queue_job: retry concurrency errors wrapped in other exceptions - #1013
RicardCForgeFlow wants to merge 1 commit into
Conversation
|
Isn't this the same issue of #1009 ? |
Hello @simahawk
As I understand it: #1009 is about errors that reach the runner as a plain |
|
This PR has the |
| and err.pgcode in PG_CONCURRENCY_ERRORS_TO_RETRY | ||
| ): | ||
| return err | ||
| err = err.__cause__ or err.__context__ |
There was a problem hiding this comment.
With raise ... from None, we explicitly tell that we want to ignore the exception chain, however from None set a __cause__ to None, but __context__ contains the parent exception. So with a straight fallback on __context__, we do not respect the choice to use from None. I would use __context__ only if __suppress_context__ is not set (https://docs.python.org/3/builtins/exceptions.html#BaseException.__suppress_context__).
Also, should we check for infinite loops. In the case that someone mistakenly set err.__cause__ = err. It is easy to do it wrong:
try:
...
except ValueError as e:
raise e from eThere was a problem hiding this comment.
Hello @guewen thanks for the review.
Both points should be solved now
7ba4d0a to
630add3
Compare

A job that fails with a serialization failure, deadlock or lock timeout is retried only if the error reaches the runner as an OperationalError. When some code wraps it in another exception (Odoo does it in auth_signup, for example), the job fails and is never retried.
The runner now looks for the concurrency error in the exception chain before deciding. Errors raised by the job itself and any other error behave as before.
Example of job failed with this kind of error and not retried: