-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Description
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