Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
simahawk opened this issue Jul 6, 2023 · 6 comments
Closed

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

simahawk opened this issue Jul 6, 2023 · 6 comments
Labels
bug stale PR/Issue without recent activity, it'll be soon closed automatically.

Comments

@simahawk
Copy link
Contributor

simahawk commented Jul 6, 2023

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]),

@simahawk simahawk added the bug label Jul 6, 2023
@simahawk
Copy link
Contributor Author

simahawk commented Jul 6, 2023

I confirm that by removing the chain from the equation, it works:

job1 = rec.delayable().action_exchange_generate()
job1.delay()

This works fine in my server action and no extra job gets created.
At first sight I don't see why it shouldn't work w/ chained jobs.
@guewen any pointer?

@guewen
Copy link
Member

guewen commented Jul 6, 2023

Hi @simahawk, looks like #546?

@simahawk
Copy link
Contributor Author

simahawk commented Jul 7, 2023

Ciao @guewen 👋 Ahhh! I missed that, thanks!

@simahawk
Copy link
Contributor Author

simahawk commented Jul 7, 2023

@guewen in regards to #546 I'm not sure this change will solve the problem. What I see is that - in my case - both jobs are re-created, not only the one that is waiting. Which means that just adding WAIT_DEPENDENCIES won't be enough.
Am I wrong?

@guewen
Copy link
Member

guewen commented Jul 7, 2023

I would need to dive into the implementation and I won't be able now 😔

IIRC the idea was that identity keys on a graph is an all or nothing thing: if all the keys are identical, then the whole graph is discarded. Otherwise the graph is enqueued.

Hope that helps

Copy link

github-actions bot commented Jan 7, 2024

There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug stale PR/Issue without recent activity, it'll be soon closed automatically.
Projects
None yet
Development

No branches or pull requests

2 participants