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

Running multiple scheduler commands for different tasks? #36

Open
Kalyse opened this issue Feb 24, 2021 · 2 comments
Open

Running multiple scheduler commands for different tasks? #36

Kalyse opened this issue Feb 24, 2021 · 2 comments

Comments

@Kalyse
Copy link

Kalyse commented Feb 24, 2021

This is going to sound totally whack, but I have intermittent issues with certain command runs failing. It only happens when the stars align, and multiple tasks run under the same scheduler run. I can't figure out the reproduction conditions, but if you imagine I have the hypothetical:

*/5 * * * * task1
*/10 * * * * task2

          • task3
  • 0 * * * task4
    30 0 * * * task5

What ends up happening, is on ten minute intervals task1, task2, task3 will run together, every 10 minutes, (they share the same common demonitor). On half hours, at midnight, task 4+5 will also run...

You get the idea - anyway, what ends up happening is my Unit of Work with Entity Manager is obviously getting screwed up by my own user-space code and it closes the Entity Manager causing weird problems and essentially commands which might end up never being ran.

It's isn't reproducible so I can't exactly nail down how to fix, but what I'd like to do is actually run the scheduler such that I run scheduler:run but instead of grabbing any task ready to run, it is limited to only task1 and task2 for one cron.
Then I might have another scheduler:run which is only going to run task3 and task4.

Is this something that's currently possible? (I have a worry that it might have problems due to the cache lock factory so likely isn't possible).

My thinking is If I could isolate groups of tasks, I am hoping I can figure out which causes the underlying problem. Other ideas and suggestions are also welcome.

@kbond
Copy link
Member

kbond commented Feb 24, 2021

I think I understand and I believe this is similar to #6. Some possible solutions:

  1. Can you play with the schedule at all to ensure they are all offset by at least a minute? (This is what I do)
  2. If these are CommandTask's, can you wrap them in a ProcessTask - this will ensure they run in separate processes
  3. If using symfony/messenger and you have an async transport, the MessageTask could queue the work to be done by your worker process.

Could any of the above work for you?

@Kalyse
Copy link
Author

Kalyse commented Feb 24, 2021 via email

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

No branches or pull requests

2 participants