#1507·predis

MasterSlaveReplication doesn't return back to slave after performing write operation

Author: gediminasivCreated Feb 5, 2025Updated Feb 19, 2025
Labelsbug

Describe the bug I was running PRedis using SncRedisBundle and noticed strange behavior using master/slave pattern. It seems that after performing some kind of a write operation (DEL in my case), where master connection is established, it never switches from $current due to this condition: https://github.com/predis/predis/blob/52489ea703aeb182b7ee7981eac69655d8f084ec/src/Connection/Replication/MasterSlaveReplication.php#L175

This fails to switch back to slave once master is selected (or maybe I am missing something here)

To Reproduce Steps to reproduce the behavior:

  1. Run any script in this sequence: GET *key* DEL *something* GET *key*.
  2. You will notice that the second GET is now running under the master connection.

Expected behavior I expect GET calls to be executed

Versions (please complete the following information):

  • Predis: 2.3
  • PHP: 8.1
  • Redis Server 7.4.1
  • OS: MacOS