forked from adrienmo/eredis_cluster
-
Notifications
You must be signed in to change notification settings - Fork 19
Home
Viktor Söderqvist edited this page Sep 22, 2020
·
2 revisions
Application eredis_cluster poolboy eredis
╷ ╷ ╷ ╷
│ │ │ │
│query │ │ │
├──────────────>│ transaction │ │
│ ├───────────────>│ query │
│ │ ├──────────>│╶╌╌╌╌╌╌╌╌╌╮
│ │ │{error,no_connection} ╎
│ │ │<┄┄┄┄┄┄┄┄┄┄┤ ∨
│ │<┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┤ │ ╭──────────────╮
│ │ {error, │ │ │ spawn │
│ │ no_connection}│ │ │reconnect_loop│
│ │ │ │ ╰──────────────╯
│ ┌┈┈┈┈┴┈┈┈┈┈┈┈┈┈┈┐ │ │ ╷
│ ┊refresh_mapping┊ │ │ ╎
│ └┈┈┈┈┬┈┈┈┈┈┈┈┈┈┈┘ │ │ ╎
│ │ │ │ ╎
│ │ transaction │ │ ╎
│ ├───────────────>│ query │ ╎
│ │ ├──────────>│ ╎
│ │ │{error, │ ╎
│ │ {error, │ no_connection} ╎
│ │ no_connection}│<┄┄┄┄┄┄┄┄┄┄┤ ╎
│ │<┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┤ │ ╎
│ ┌┄┄┄┄┴┄┄┄┄┄┄┄┄┄┄┐ │ │ ╎
│ ┆refresh_mapping┆ │ │<╌╌╌╌╌╌╌╌╌╯
│ └┄┄┄┄┬┄┄┄┄┄┄┄┄┄┄┘ │ │
╵ ╵ ╵ ╵
- Eredis returns
{error, no_connection}
while reconnect is ongoing.- Another option would be to let a request block for a while if re-connect is ongoing.
- Poolboy doesn't know which workers have a working connection and which don't.
- If we use
{strategy, fifo}
in the poolboy options, at least we don't get the reconnecting worker over and over.
- If we use
- Eredis_cluster handles
{error, no_connection}
by refreshing the mapping and then trying again, possibly using another eredis client instance. The reason for the connection being down may or may not be that the Redis instance is down and the cluster is restructering itself. If it is, then refreshing the mapping resolves the situation and causes the pool of connections to the disconnected Redis instance to be shut down.