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

asyncio_redis should wait for server restart #144

Open
crusaderky opened this issue Aug 10, 2020 · 0 comments
Open

asyncio_redis should wait for server restart #144

crusaderky opened this issue Aug 10, 2020 · 0 comments

Comments

@crusaderky
Copy link
Contributor

crusaderky commented Aug 10, 2020

Use case

An asyncio_redis connection with auto_reconnect=True is already connected to the Redis server.
The Redis server unexpectedly and randomly crashes and is resurrected shortly thereafter at the same host and port by a nanny, e.g. Kubernetes.

Current asyncio_redis behaviour

Application-level requests to the server fail until the connection is reestablished.

Expected behaviour

Application-level requests are silently enqueued and wait until the connection is reestablished.
If a connection timeout were to be implemented in create(), the reconnection attempt should use the same timeout.

POC

Tested on Ubuntu Linux x64, asyncio_redis 0.16.0, redis 5.0.3

import asyncio
import subprocess

import asyncio_redis


async def main():
    server = subprocess.Popen(["redis-server"])
    try:
        client = await asyncio_redis.Pool.create()
        await client.ping()
        server.kill()
        server = subprocess.Popen(["redis-server"])
        await asyncio.sleep(1)
        await client.ping()
    finally:
        server.kill()


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

The above runs with no error.
After commenting out the sleep(1): asyncio_redis.exceptions.ConnectionLostError: None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant