Skip to content

Commit 8ae4e55

Browse files
kokhloauvipy
andauthored
fix(redis): treat stale-fd KeyError as a connection error (#2592)
* fix(redis): treat stale-fd KeyError as a connection error * Add regression test: KeyError is a redis transport connection error * style: blank line between test methods * Remove file committed to the wrong path * style: blank line between test methods * Fix tuple closing in connection_errors * Resolve Transport at module level in the regression test * Update t/unit/transport/test_redis.py --------- Co-authored-by: Asif Saif Uddin {"Auvi":"অভি"} <auvipy@gmail.com>
1 parent 26e558a commit 8ae4e55

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

kombu/transport/redis.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,13 @@ def get_redis_error_classes():
173173
exceptions.ConnectionError,
174174
exceptions.BusyLoadingError,
175175
exceptions.AuthenticationError,
176-
exceptions.TimeoutError)),
176+
exceptions.TimeoutError,
177+
# A stale fd can still fire on_readable for a channel that was
178+
# already dropped after a broker restart (#2582): the poller
179+
# guard from #2561 makes the common path a debug log, but any
180+
# KeyError that still escapes must be treated as a connection
181+
# error so the consumer reconnects instead of dying.
182+
KeyError)),
177183
(virtual.Transport.channel_errors + (
178184
DataError,
179185
exceptions.InvalidResponse,

t/unit/transport/test_redis.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2921,6 +2921,10 @@ def test_handle_event(self):
29212921

29222922
p.handle_event(13, ~(redis.READ | redis.ERR))
29232923

2924+
def test_connection_errors_include_keyerror(self):
2925+
errors = redis.Transport.connection_errors
2926+
assert KeyError in errors
2927+
29242928
def test_on_readable_ignores_unmapped_fd(self):
29252929
p = self.Poller()
29262930
assert 35 not in p._fd_to_chan

0 commit comments

Comments
 (0)