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

[Lock] Fix StoreFactory to accept same DSN syntax as AbstractAdapter #36291

Merged
merged 1 commit into from Oct 3, 2020

Conversation

Jontsa
Copy link
Contributor

@Jontsa Jontsa commented Mar 31, 2020

Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #35350
License MIT
Doc PR

Updates Symfony\Component\Lock\Store\StoreFactory to accept same DSN syntax as Symfony\Component\Cache\Adapter\AbstractAdapter which is used to create Redis class instance.

@Jontsa Jontsa requested a review from jderusse as a code owner Mar 31, 2020
@Jontsa Jontsa changed the title Ticket 35350 [Lock] Fix StoreFactory to accept same DSN syntax as AbstractAdapter Mar 31, 2020
Copy link
Member

@jderusse jderusse left a comment

I'm fine with this PR form a technical point of view.

But you have to keep in mind that using Lock with a cluster of Redis/memcached is not reliable: by default replication is asynchronous, meaning, one process is able to acquire a Lock, which may not be propagated to replica, and, if primary has a failure, another process will be able to acquire the same lock .

You should use a CombineStore to achieve a HA with multiple Memcached/Redis

nb: This is already recommended in Documentation: https://symfony.com/doc/current/components/lock.html#id6

I think we should open a PR to add a WAIT in RedisStore that assure that a least 50%+1 servers in the cluster are synchronized

@nicolas-grekas nicolas-grekas added this to the 4.4 milestone Apr 3, 2020
@Nyholm Nyholm mentioned this pull request May 28, 2020
3 tasks
@jderusse
Copy link
Member

@jderusse jderusse commented Aug 6, 2020

fixed by #37590

@fabpot
Copy link
Member

@fabpot fabpot commented Aug 6, 2020

@jderusse Shall we close then? Should we also close #35350?

@Jontsa
Copy link
Contributor Author

@Jontsa Jontsa commented Aug 6, 2020

#37590 partially fixes this issue. StoreFactory still does not support the same exact DSN syntax as Symfony\Component\Cache\Adapter\AbstractAdapter for Redis connections.

But this PR can be closed if we do not want to allow DSN with multiple Redis hosts for Locks.

@jderusse
Copy link
Member

@jderusse jderusse commented Aug 6, 2020

You're right @Jontsa.

Can you, please, rebase your PR and keep the part about DSN pattern?

@fabpot fabpot added the Lock label Aug 11, 2020
@fabpot
Copy link
Member

@fabpot fabpot commented Sep 5, 2020

@Jontsa Do you time to finish this PR?

@fabpot
Copy link
Member

@fabpot fabpot commented Sep 11, 2020

@Jontsa I think you will need to rebase on the current 4.4 branch as there are some conflicts.

Copy link
Member

@jderusse jderusse left a comment

A small comment about change in tests.

Then, I'm 👍 with the PR

}
if (class_exists(\Redis::class) && class_exists(AbstractAdapter::class)) {
if ((class_exists(\Redis::class) || class_exists(\Predis\Client::class)) && class_exists(AbstractAdapter::class)) {
Copy link
Member

@jderusse jderusse Sep 30, 2020

Choose a reason for hiding this comment

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

Revert this.

The purpose of this check is to avoid failing tests when the extension is not installed.

By checking if Predis is installed (which is always true because in require-dev) this breaks the initial check.

Copy link
Member

@xabbuh xabbuh Oct 5, 2020

Choose a reason for hiding this comment

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

fixed in 6a79f3e

fabpot
fabpot approved these changes Oct 3, 2020
Copy link
Member

@fabpot fabpot left a comment

Taking over

@fabpot
Copy link
Member

@fabpot fabpot commented Oct 3, 2020

Thank you @Jontsa.

@fabpot fabpot merged commit 35e04d9 into symfony:4.4 Oct 3, 2020
3 of 5 checks passed
This was referenced Oct 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants