SchedulerBundle: bug(scheduler): consuming tasks in separate processes
Task is running multiple times.
with the following tasks configuration :
scheduler_bundle:
transport:
dsn: 'doctrine://default?execution_mode=first_in_first_out'
tasks:
foo:
type: 'command'
command: 'app:foo'
description: '3mins task'
single_run: true
bar:
type: 'command'
command: 'app:bar'
description: '1mins task'
single_run: true
and a cron configuration : * * * * * cd /path-to-your-project && php bin/console scheduler:consume >> /dev/null 2>&1
the first scheduler:consume output :
[OK] Task "bar" succeed. (Duration: 1 min, Memory used: 28.0 MiB)
one minute later second call scheduler:consume output :
[OK] Task "foo" succeed. (Duration: 3 mins, Memory used: 27.9 MiB)
[OK] Task "bar" succeed. (Duration: 1 min, Memory used: 28.0 MiB)
we can see that the bar task is executed twice. How can we ensure the uniqueness of tasks.
I hope to be clear enough in my explanation 😄
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 78 (78 by maintainers)
issue/92same behaviorbaris executed twiceOk, I’ve probably found a solution, sadly, the solution could be related to https://github.com/Guikingone/SchedulerBundle/pull/107 as the worker continues to found tasks even if current date is within the minute range 🙁
perfect we can understand each other 😆
Ok, good news (at least, a better one that the others related to this issue 😄), I’m finally able to reproduce the issue when it comes to a “shared” lock on a “long-running” task, I’ve scheduled a 3 minutes
single_runtask followed by a 1 minutesingle_runtask.When using 2 processes, the first one is executed then the second is executed in the second process THEN the first process tries to execute again the first task.
Hi @jvancoillie 👋🏻
I’ve pushed a refactoring on
dev-issue/92, be sure to rebase fully and clear the cache before testing it, there’s some changes on the DIC part and the worker arguments, thanks 🙂Hi @jvancoillie 👋🏻
Could you test this issue against
0.4.4?Thanks 🙂