Nordix / hiredis-cluster

C client library for Valkey/Redis Cluster. This project is used and sponsored by Ericsson. It is a fork of the now unmaintained hiredis-vip.
BSD 3-Clause "New" or "Revised" License
87 stars 42 forks source link

Follow MOVED redirect and update slot mapping concurrently #164

Closed zuiderkwast closed 1 year ago

zuiderkwast commented 1 year ago

When receiving a MOVED redirect, follow the redirect immediately and perform the slot mapping update in the background, rather than first doing the slot map update and then retry the command using the updated slot map.

In the sync API, the MOVED redirect is followed and the slot mapping update is performed concurrently. When the reply is returned to the caller, the slot mapping update is complete.

In the async API, an asynchronous slot mapping update is started while the MOVED redirect is followed. There is no guarantee that the slot mapping update is completed when the reply to command that triggered the MOVED redirect is returned to the caller.

Before this patch, a new connection was opened to a node to fetch the slot mapping synchronously (even in the async API). With this patch, the connection to the node which returned the MOVED redirect is reused for fetching the updated slot mapping.