Skip to content

[Lock] MongoDbStore reports a failure to release #37139

@kralos

Description

@kralos

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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy