Skip to content

Lock MongoDbStore error when using replica set and connected to secondary #58397

@dimitar-kunchev

Description

@dimitar-kunchev

Symfony version(s) affected

7

Description

A rare problem exists when using Symfony Locks with MongoDbStore connected to a replica set. When releasing the lock it throws LockReleasingException. I have traced the problem that the MongoDBStore->exists method does not specify read preference. As a result, the Lock gets deleted (on the primary) but then checks if it exists on the secondary which may not be synced yet.
The only method I have thought of to resolve this (besides catching the exception) is to specify read preference at the connection level.

How to reproduce

Setup an environment with multiple mongo instances
Connect to a secondary instance
Implement a lock with MongoDBStore
Try to acquire and release the lock multiple times

Possible Solution

Add ReadPreference parameter to the executeQuery call in MongoDBStore->exists method

Additional Context

No response

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