-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Lock] Add $prefix
parameter to avoid collision with FlockStore
#57857
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
base: 7.4
Are you sure you want to change the base?
Conversation
3ed7270
to
ec32409
Compare
$prefix
parameter to avoid collision with FlockStore
7.2 | ||
--- | ||
|
||
* Add parameter `$prefix` to `FlockStore::__construct()` |
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.
* Add parameter `$prefix` to `FlockStore::__construct()` | |
* Add `$prefix` parameter to `FlockStore::__construct()` |
* | ||
* @throws LockStorageException If the lock directory doesn’t exist or is not writable | ||
*/ | ||
public function __construct(?string $lockPath = null) | ||
public function __construct(?string $lockPath = null, ?string $prefix = null) |
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.
public function __construct(?string $lockPath = null, ?string $prefix = null) | |
public function __construct( | |
?string $lockPath = null, | |
private ?string $prefix = null, | |
) |
We can use CPP (constructor property promotion here)
Didn't the |
It does. But by default, everything is written in the temp directory and if two Symfony projects use the default configuration they will share the lock. The purpose of this PR is to provide a way to insulate by default the lock per Symfony instance (using the |
What about this PR ? The idea is to allow multiple Symfony project to use |
I would do it diffently: since by default we have a shared lock space, we should still do that, or we might break apps. |
Currently if two Symfony projects are hosted on the same server and used the same key for a lock using the default
FlockStore
, the two applications shared the same lock.So I suggest adding a prefix in the
FlockStore
constructor to isolate the lock to the current project and avoid collision.This prefix could be initialized with the
kernel.secret
parameter by default.To avoid BC, I add the
flock-exclusive
lock key configuration.I know this could be done by changing the path a the
FlockStore
, but this "exclusive lock" could be the default behaviour of Symfony in the next major release.