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

New Feature: onOneServer #42

Closed
gennadiylitvinyuk opened this issue Oct 24, 2022 · 9 comments
Closed

New Feature: onOneServer #42

gennadiylitvinyuk opened this issue Oct 24, 2022 · 9 comments
Labels
bug Something isn't working
Milestone

Comments

@gennadiylitvinyuk
Copy link

Description
An option to indicate that the task should run on only one server, similar to laravel's onOneServer like described in https://laravel.com/docs/9.x/scheduling#running-tasks-on-one-server

It is not possible to achieve the same results with preventOverlapping because the current implementation of preventOverlapping allows passing only locks implementing BlockingStoreInterface. It leads task execution once per server, but not in the same time.

@PabloKowalczyk
Copy link
Member

PabloKowalczyk commented Oct 25, 2022

Hello, blocking store is not required, it was fixed in docs and code do not acquire blocking locks. preventOverlapping should deliver same functionality as onOneServer.

Did you test preventOverlapping with remote store like PDO?

@gennadiylitvinyuk
Copy link
Author

gennadiylitvinyuk commented Oct 26, 2022

Unfortunately I didn't mention it, I refer to 3.4 but in 3.5 it is still the same

The check for BlockingStoreInterface is still there, if I understand it correctly.

crunz/src/Event.php

Lines 721 to 732 in 9148a14

*/
public function preventOverlapping(object $store = null)
{
if (null !== $store && !($store instanceof BlockingStoreInterface || $store instanceof StoreInterface)) {
$legacyClass = StoreInterface::class;
$newClass = BlockingStoreInterface::class;
$actualClass = \get_class($store);
throw new \RuntimeException(
"Instance of '{$newClass}' or '{$legacyClass}' is expected, '{$actualClass}' provided"
);
}

And yes, I tried it with PDO Store

@PabloKowalczyk
Copy link
Member

PabloKowalczyk commented Oct 26, 2022

The check for BlockingStoreInterface is still there, if I understand it correctly.

Yes, but StoreInterface is also accepted. Symfony changed Lock component in 5.x.

And yes, I tried it with PDO Store

Does it work?

@gennadiylitvinyuk
Copy link
Author

No, at least in v3.4 (PHP 7.4) there is no 'Symfony\Component\Lock\StoreInterface available.
That leads for example to Exception

In Event.php line 729:

  Instance of 'Symfony\Component\Lock\BlockingStoreInterface' or 'Symfony\Component\Lock\StoreInterface' is expected, 'Symfony\Component\Lock\Store\DoctrineDbalStore' provided  

@PabloKowalczyk
Copy link
Member

Which Symfony Lock version?

@gennadiylitvinyuk
Copy link
Author

Which Symfony Lock version?

symfony/lock v5.4.10

@PabloKowalczyk
Copy link
Member

OK, looks like bug in Crunz, will be fixed soon.

@PabloKowalczyk
Copy link
Member

@gennadiylitvinyuk please try #44

@gennadiylitvinyuk
Copy link
Author

@gennadiylitvinyuk please try #44

Yes, it works this way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants