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

Single Server double execution #90

Open
maciekpaprocki opened this issue Feb 17, 2025 · 0 comments
Open

Single Server double execution #90

maciekpaprocki opened this issue Feb 17, 2025 · 0 comments

Comments

@maciekpaprocki
Copy link

I am not sure if i am not doing something stupid.

Seems that single server only works correctly if the commands are triggered at exactly the same time and are long enough.

Example

I run script:

php bin/console schedule:run &
php bin/console schedule:run &
$schedule->onSingleServer()
$schedule->addCommand('app:test-slack "Test message"')
       ->onSingleServer()
       ->identifiedBy('app:test-slack "Test message"')
        ->everyMinute();

everything fine

Then I do bash:

php bin/console schedule:run &
sleep 1
php bin/console schedule:run &

I receive two Slack messages

Then when I add sleep(2); inside of my app:test-slack I receive one again.

That means that lock only works until the other server is still running the command. That is potentially dangerous. The issue is, that some tasks can be very quick. Some servers might be delayed with triggering cron ( for example when the cache is not warmed )

Fix:

Lock should probably be for a minute and with a minimal timeout of 60 seconds. Not sure how it works from the symfony lock perspective. Don't think there's ready made mechanism and all implementations I can think of are a bit sketchy. Happy to implement though if pointed in right direction.

@maciekpaprocki maciekpaprocki changed the title Single Server Single Server double execution Feb 17, 2025
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

1 participant