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] MongoDbStore reports a failure to release #37139
Labels
Comments
kralos
pushed a commit
to kralos/symfony
that referenced
this issue
Jun 8, 2020
kralos
pushed a commit
to kralos/symfony
that referenced
this issue
Jun 8, 2020
… reads from secondaries
@Baachi I suspect this problem also exists in |
kralos
pushed a commit
to kralos/symfony
that referenced
this issue
Jun 10, 2020
kralos
pushed a commit
to kralos/symfony
that referenced
this issue
Jun 10, 2020
fabpot
added a commit
that referenced
this issue
Jun 10, 2020
…s (kralos) This PR was squashed before being merged into the 5.1 branch. Discussion ---------- [Lock] Fixed reading locks from replica set secondary nodes | Q | A | ------------- | --- | Branch? | 5.1 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #37139 | License | MIT | Doc PR | symfony/symfony-docs#13775 Force lock existence query to use `readPreference=primary` in case the given mongo connection is using any of the following `readPreference`s: * primaryPreferred * secondary * secondaryPreferred * nearest Any of the above would fail if a secondary node is queried during a lock release. Commits ------- ebf7eaf [Lock] Fixed reading locks from replica set secondary nodes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Symfony version(s) affected: 5.1.0
Description
When using
MongoDbStore
against areplicaSet
with a connectionreadPreference
other thanprimary
(the default), the store falsely reports locks don't release. This is becauseSymfony\Component\Lock\Lock::release()
deletes the key then immediately reads from the store in order to check if the lock was successfully released. The key eviction may not have propagated the replica set at this time and returns exists (true) causing Lock to think the release failed.How to reproduce
Set up a mongo replicaSet and connect to it from your application with:
readPreference=secondary
in your Mongo connection URI. Then try to acquire and release a lock. You should get a:Symfony\Component\Lock\Exception\LockReleasingException
Possible Solution
We should always use
readPreference=primary
for all semephore queries (there's only 1:MongoDbStore::exists
).Additional context
https://docs.mongodb.com/manual/core/read-preference/
The text was updated successfully, but these errors were encountered: