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

Appearance settings

[Lock] MongoDbStore reports a failure to release #37139

Copy link
Copy link
Closed
@kralos

Description

@kralos
Issue body actions

Symfony version(s) affected: 5.1.0

Description
When using MongoDbStore against a replicaSet with a connection readPreference other than primary (the default), the store falsely reports locks don't release. This is because Symfony\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/

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.