Skip to content

[14.0] identity_exact not working w/ chained jobs? #552

Description

@simahawk

I have this piece of code

        for rec in new_records:
            job1 = rec.delayable().action_exchange_generate()
            if not skip_send:
                # Chain send job
                job1.on_done(rec.delayable().action_exchange_send())
            job1.delay()

I inject identity_key=identity_exact here.

Here I test that no duplicated job gets created but it does not work.

    def test_job(self):
        with trap_jobs() as trap:
            self.backend._check_output_exchange_sync(record_ids=self.record.ids)
            trap.assert_jobs_count(2)
            trap.assert_enqueued_job(
                self.backend.exchange_record_model.action_exchange_generate,
            )
            trap.assert_enqueued_job(
                self.backend.exchange_record_model.action_exchange_send,
            )
            self.backend._check_output_exchange_sync(record_ids=self.record.ids)
            self.backend._check_output_exchange_sync(record_ids=self.record.ids)
            # identity key should prevent having new jobs
            trap.assert_jobs_count(2)

I have 6 jobs at the end while I expect to have still 2 jobs only.

I've inspected the identity keys of those jobs and they all match 🤔
I also checked if job.job_record_with_same_identity_key gets called: it is called but it cannot find the jobs.
Flushing does not help.

I've created a silly server action to test the same piece of code via UI on the same record and gives me the same result...

Am I doing something wrong or we have a bug w/ chained jobs?

Side note: unless I'm mistaken I think job.job_record_with_same_identity_key does not search for all possible states when you have a job that is waiting for a dependency here

("state", "in", [PENDING, ENQUEUED]),

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugstalePR/Issue without recent activity, it'll be soon closed automatically.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions