Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: [Python] Redis disconnect sends into error loop and hangs app #3103

Open
1 task done
RolandasRazma opened this issue Feb 22, 2025 · 1 comment
Open
1 task done
Labels
bug Something isn't working

Comments

@RolandasRazma
Copy link

RolandasRazma commented Feb 22, 2025

Version

2.11.0

Platform

Python

What happened?

Redis disconnect send python app into error loop hanging app

How to reproduce.

stop redis

async def processor(job: Job, job_token: str):
    pass


async def main():
    # Shutdown event
    shutdown_event = asyncio.Event()

    def signal_handler(signal, frame):
        logger.info(f"got signal {signal}")
        shutdown_event.set()

    # Assign signal handlers to SIGTERM and SIGINT
    signal.signal(signal.SIGTERM, signal_handler)
    signal.signal(signal.SIGINT, signal_handler)

    worker = Worker(name="queue_name_1", processor=processor)

    await shutdown_event.wait()
    # close the worker
    await worker.close()


if __name__ == "__main__":
    asyncio.run(main())

Relevant log output

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/xxx/lib/python3.12/site-packages/bullmq/utils.py", line 11, in extract_result
    return job_task.result()
           ^^^^^^^^^^^^^^^^^
  File "/xxx/lib/python3.12/site-packages/bullmq/worker.py", line 122, in getNextJob
    job_instance = await self.moveToActive(token)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/xxx/lib/python3.12/site-packages/bullmq/worker.py", line 126, in moveToActive
    result = await self.scripts.moveToActive(token, self.opts)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/xxx/lib/python3.12/site-packages/bullmq/scripts.py", line 478, in moveToActive
    result = await self.commands["moveToActive"](keys=keys, args=args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/xxx/lib/python3.12/site-packages/redis/commands/core.py", line 5572, in __call__
    return await client.evalsha(self.sha, len(keys), *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/xxx/lib/python3.12/site-packages/redis/asyncio/client.py", line 611, in execute_command
    conn = self.connection or await pool.get_connection(command_name, **options)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/xxx/lib/python3.12/site-packages/redis/asyncio/connection.py", line 1064, in get_connection
    await self.ensure_connection(connection)
  File "/xxx/lib/python3.12/site-packages/redis/asyncio/connection.py", line 1097, in ensure_connection
    await connection.connect()
  File "/xxx/lib/python3.12/site-packages/redis/asyncio/connection.py", line 289, in connect
    raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error Multiple exceptions: [Errno 61] Connect call failed ('127.0.0.1', 6379), [Errno 61] Connect call failed ('::1', 6379, 0, 0) connecting to localhost:6379.
Traceback (most recent call last):
  File "/xxx/lib/python3.12/site-packages/redis/asyncio/connection.py", line 281, in connect
    await self.retry.call_with_retry(
  File "/xxx/lib/python3.12/site-packages/redis/asyncio/retry.py", line 59, in call_with_retry
    return await do()
           ^^^^^^^^^^
  File "/xxx/lib/python3.12/site-packages/redis/asyncio/connection.py", line 697, in _connect
    reader, writer = await asyncio.open_connection(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/xxx/lib/python3.12/asyncio/streams.py", line 48, in open_connection
    transport, _ = await loop.create_connection(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/xxx/lib/python3.12/asyncio/base_events.py", line 1140, in create_connection
    raise OSError('Multiple exceptions: {}'.format(
OSError: Multiple exceptions: [Errno 61] Connect call failed ('127.0.0.1', 6379), [Errno 61] Connect call failed ('::1', 6379, 0, 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/xxx/lib/python3.12/site-packages/bullmq/utils.py", line 11, in extract_result
    return job_task.result()
           ^^^^^^^^^^^^^^^^^
  File "/xxx/lib/python3.12/site-packages/bullmq/worker.py", line 122, in getNextJob
    job_instance = await self.moveToActive(token)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/xxx/lib/python3.12/site-packages/bullmq/worker.py", line 126, in moveToActive
    result = await self.scripts.moveToActive(token, self.opts)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/xxx/lib/python3.12/site-packages/bullmq/scripts.py", line 478, in moveToActive
    result = await self.commands["moveToActive"](keys=keys, args=args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/xxx/lib/python3.12/site-packages/redis/commands/core.py", line 5572, in __call__
    return await client.evalsha(self.sha, len(keys), *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/xxx/lib/python3.12/site-packages/redis/asyncio/client.py", line 611, in execute_command
    conn = self.connection or await pool.get_connection(command_name, **options)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/xxx/lib/python3.12/site-packages/redis/asyncio/connection.py", line 1064, in get_connection
    await self.ensure_connection(connection)
  File "/xxx/lib/python3.12/site-packages/redis/asyncio/connection.py", line 1097, in ensure_connection
    await connection.connect()
  File "/xxx/lib/python3.12/site-packages/redis/asyncio/connection.py", line 289, in connect
    raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error Multiple exceptions: [Errno 61] Connect call failed ('127.0.0.1', 6379), [Errno 61] Connect call failed ('::1', 6379, 0, 0) connecting to localhost:6379.
Traceback (most recent call last):
  File "/xxx/lib/python3.12/site-packages/redis/asyncio/connection.py", line 281, in connect
    await self.retry.call_with_retry(
  File "/xxx/lib/python3.12/site-packages/redis/asyncio/retry.py", line 59, in call_with_retry
    return await do()
           ^^^^^^^^^^
  File "/xxx/lib/python3.12/site-packages/redis/asyncio/connection.py", line 697, in _connect
    reader, writer = await asyncio.open_connection(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/xxx/lib/python3.12/asyncio/streams.py", line 48, in open_connection
    transport, _ = await loop.create_connection(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/xxx/lib/python3.12/asyncio/base_events.py", line 1140, in create_connection
    raise OSError('Multiple exceptions: {}'.format(
OSError: Multiple exceptions: [Errno 61] Connect call failed ('127.0.0.1', 6379), [Errno 61] Connect call failed ('::1', 6379, 0, 0)

During handling of the above exception, another exception occurred:

Code of Conduct

  • I agree to follow this project's Code of Conduct
@RolandasRazma RolandasRazma added the bug Something isn't working label Feb 22, 2025
@RolandasRazma
Copy link
Author

RolandasRazma commented Feb 24, 2025

Actually I see same behavior no matter processor(job: Job, job_token: str):. Just start your sample code without Redis alive (updated report)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant