Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Lock] Add$prefix parameter to avoid collision withFlockStore#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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
jdecool wants to merge1 commit intosymfony:7.4
base:7.4
Choose a base branch
Loading
fromjdecool:lock-flock-collision

Conversation

jdecool
Copy link
Contributor

@jdecooljdecool commentedJul 28, 2024
edited
Loading

QA
Branch?7.2
Bug fix?no
New feature?yes
Deprecations?no
Issues-
LicenseMIT

Currently if two Symfony projects are hosted on the same server and used the same key for a lock using the defaultFlockStore, the two applications shared the same lock.

So I suggest adding a prefix in theFlockStore constructor to isolate the lock to the current project and avoid collision.

This prefix could be initialized with thekernel.secret parameter by default.

To avoid BC, I add theflock-exclusive lock key configuration.

I know this could be done by changing the path a theFlockStore, but this "exclusive lock" could be the default behaviour of Symfony in the next major release.

@symfonysymfony deleted a comment fromcarsonbotJul 28, 2024
@OskarStarkOskarStark changed the title[Lock] Add prefix argument to avoid collision with FlockStore[Lock] Add$prefix parameter to avoid collision withFlockStoreAug 2, 2024
7.2
---

* Add parameter `$prefix` to `FlockStore::__construct()`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
* Addparameter`$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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
publicfunction __construct(?string$lockPath =null, ?string$prefix =null)
publicfunction __construct(
?string$lockPath =null,
private ?string$prefix =null,
)

We can use CPP (constructor property promotion here)

@jderusse
Copy link
Member

Didn't the$lockPath parameter solve the issue?

@jdecool
Copy link
ContributorAuthor

Didn't the $lockPath parameter solve the issue?

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 theAPP_SECRET).

@jdecool
Copy link
ContributorAuthor

What about this PR ?

The idea is to allow multiple Symfony project to useflock LockStore on the same server without being block each other by default.

@nicolas-grekas
Copy link
Member

I would do it diffently: since by default we have a shared lock space, we should still do that, or we might break apps.
Then, for apps that need split lock spaces, each could define a dedicated $lockPath. We might make this easy by adding a namespace or prefix config option.
But since $lockPath already provides a way to do this split, we should leverage it. And I would definitely not use the secret for that (and I wouldn't split by default).

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@OskarStarkOskarStarkOskarStark left review comments

@jderussejderusseAwaiting requested review from jderussejderusse is a code owner

Assignees
No one assigned
Projects
None yet
Milestone
7.4
Development

Successfully merging this pull request may close these issues.

6 participants
@jdecool@jderusse@nicolas-grekas@OskarStark@fabpot@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp