Skip to content

Commit

Permalink
Fix: Fanout exchange messages mixed across virtual databases in Redis…
Browse files Browse the repository at this point in the history
… sentinel
  • Loading branch information
huyenvu2101 authored and auvipy committed May 4, 2024
1 parent a56abf6 commit 4d28194
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions kombu/transport/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1433,6 +1433,8 @@ def _sentinel_managed_pool(self, asynchronous=False):
).connection_pool

def _get_pool(self, asynchronous=False):
params = self._connparams(asynchronous=asynchronous)
self.keyprefix_fanout = self.keyprefix_fanout.format(db=params['db'])
return self._sentinel_managed_pool(asynchronous)


Expand Down
12 changes: 12 additions & 0 deletions t/unit/transport/test_redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1634,6 +1634,18 @@ def test_method_called(self):
connection.channel()
p.assert_called()

def test_keyprefix_fanout(self):
from kombu.transport.redis import SentinelChannel
with patch.object(SentinelChannel, '_sentinel_managed_pool'):
connection = Connection(
'sentinel://localhost:65532/1',
transport_options={
'master_name': 'not_important',
},
)
channel = connection.channel()
assert channel.keyprefix_fanout == '/1.'

def test_getting_master_from_sentinel(self):
with patch('redis.sentinel.Sentinel') as patched:
connection = Connection(
Expand Down

0 comments on commit 4d28194

Please sign in to comment.