[19.0][FIX] edi_queue_oca: propagate failed jobs to exchanges#321
[19.0][FIX] edi_queue_oca: propagate failed jobs to exchanges#321yankinmax wants to merge 1 commit into
Conversation
When an EDI queue job reached its maximum retries, only the queue job was marked as failed while the related exchange remained pending. Propagate terminal send, receive, and process job failures to the corresponding exchange error state, including the exception message and traceback.
|
Hello @simahawk can you pls take a look? |
|
|
||
| def write(self, vals): | ||
| result = super().write(vals) | ||
| if vals.get("state") == "failed": |
There was a problem hiding this comment.
Maybe there’s an opportunity to create an "on-failure" hook in the queue_job module
https://github.com/OCA/queue/blob/19.0/queue_job/models/queue_job.py#L268
There was a problem hiding this comment.
FWIW when the job is failing, only the job object will be updated through a dedicated function for failure,
and then the modified values are going to be stored on the odoo record: https://github.com/OCA/queue/blob/19.0/queue_job/controllers/main.py#L187-L188
|
|
||
| def write(self, vals): | ||
| result = super().write(vals) | ||
| if vals.get("state") == "failed": |
There was a problem hiding this comment.
Direct SQL updates executed by the queue_job runner will bypass this logic https://github.com/OCA/queue/blob/19.0/queue_job/jobrunner/runner.py#L217
In the situation where the number of retries exceeds the maximum allowed, the job is marked as "failed" with the error "JobFoundDead."
grindtildeath
left a comment
There was a problem hiding this comment.
Idea looks good, but IMO there's still something wrong because:
- We have this https://github.com/OCA/edi-framework/blob/18.0/edi_core_oca/models/edi_backend.py#L247-L253 in the core module although we do not depend on queue_job.
- What we try to solve here is to have the exchange record in an error state when the number of retries from a job is exhausted.
|
|
||
| def write(self, vals): | ||
| result = super().write(vals) | ||
| if vals.get("state") == "failed": |
There was a problem hiding this comment.
FWIW when the job is failing, only the job object will be updated through a dedicated function for failure,
and then the modified values are going to be stored on the odoo record: https://github.com/OCA/queue/blob/19.0/queue_job/controllers/main.py#L187-L188
| supported_methods = { | ||
| "action_exchange_process", | ||
| "action_exchange_receive", | ||
| "action_exchange_send", | ||
| } |
There was a problem hiding this comment.
Why don't we have action_exchange_generate ❓
I'd suggest to have a constant variable with the functions list, so that it can be relied on here and in the _register_hook.
|
Here's another attempt at solving the same issue: #323 |
|
Alternative implementation: #324 |
When an EDI queue job reached its maximum retries, only the queue job was marked as failed while the related exchange remained pending.
Propagate terminal send, receive, and process job failures to the corresponding exchange error state, including the exception message and traceback.