Skip to content

[19.0] [FIX] edi_queue_oca: drop file checksum from job identity key - #380

Closed
ivantodorovich wants to merge 1 commit into
OCA:19.0from
camptocamp:19.0-fix-edi_queue_oca-identity-key
Closed

ivantodorovich wants to merge 1 commit into
OCA:19.0from
camptocamp:19.0-fix-edi_queue_oca-identity-key

Conversation

@ivantodorovich

Copy link
Copy Markdown
Contributor

Don't queue a second send job for a record whose send is already chained to its generation

The job identity key includes the file checksum:

hasher = identity_exact_hasher(job_)
# Include files checksum
hasher.update(
str(sorted(job_.recordset.mapped("exchange_filechecksum"))).encode("utf-8")
)
return hasher.hexdigest()

But the send job chained to the generation is queued before the file exists, so its key holds the checksum of an empty file:

def action_exchange_generate_send_chained(self):
job1 = self.delayable().action_exchange_generate()
# Chain send job.
# Raise prio to max to send the record out as fast as possible.
job1.on_done(self.delayable(priority=0).action_exchange_send())
job1.delay()

If the send doesn't run right away (e.g. with a job ETA), the output cron finds the record in output_pending and queues another send, this time with the checksum of the generated file. The keys don't match, so it isn't deduplicated:

if rec.edi_exchange_state == "output_pending":
rec.action_exchange_send()

Steps to reproduce:

  1. Enable the job ETA on an output exchange type.
  2. Create a record and generate + send it: the generate job runs, the send job waits for the ETA.
  3. Let the output cron run.
  4. When the ETA is reached, both send jobs run at the same time, and the record is sent twice ❌

The checksum isn't needed: the jobs read the file when they run, not when they're queued, so a pending job already sends the latest content. The solution is to drop it and use the plain identity_exact instead.

The send job chained to a generation is queued before the file exists, so
the output cron queued a second send for the same record, and both ran.
The jobs read the file when they run, the checksum is not needed.
@ivantodorovich

Copy link
Copy Markdown
Contributor Author

Actually this causes a regression in case of a failed generate job, that would keep its dependant send job forever waiting dependencies -- and that counts for the identity_key deduplication.

The issue is bigger than this, so I'm putting it on hold for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants