-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[5.4] add OverlappingStrategy for Schedule/Event #18295
[5.4] add OverlappingStrategy for Schedule/Event #18295
Conversation
So this doesn't actually change the current behavior? What does your custom strategy look like? |
I check if the artisan command is running already by filtering the output of But I can include my custom strategy in the PR if you want me to? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to be able to modify the expiration of the mutex in configs
|
||
public function prevent(Event $event) | ||
{ | ||
$this->cache->put($event->mutexName(), true, 1440); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1440 = 24 hours.
Depending on your workload, if one of your servers goes down, you might not want to wait a full day for the key to expire and resume schedule.
@alain-lf Adding the cache entry lifetime for the overlapping check to the config would be an option, but I think this would be to much change for a minor feature change. And also a shorter cache entry lifetime does not solve the overlapping problem when the process dies, it only reduces the time until the process can be restarted. Maybe the @taylorotwell what do you think about the config for the mutex cache entry liftetime? |
You wouldn't really want a global config item for this. It would be job specific. |
That's true, I will skip this for the PR because it is targeting the extensibility of the overlapping strategy. Is the PR ready for merging or do you need additional infos? |
Attempt to use atomic cache operation when checking for overlaps.
No need to keep pinging. I will eventually look at it. |
The
withoutOverlapping
implementation in theEvent
class is not working in all cases. For example when the process gets killed, the cache entry is not removed and the scheduled command will not start again until the cache entry expires.Therefore I've implemented an
OverlappingStrategy
Interface to be able to override the standard cache strategy. The interface specifies 3 methods:To be compatible with the current implementation I've added a
CacheOverlappingStrategy
that provides the same functionality as the current implementation.