ledgetech / lua-resty-redis-connector

Connection utilities for lua-resty-redis
234 stars 71 forks source link

Re-create and subscribe to the same PUBSUB channel in case there is a Redis failover #35

Closed yyibin closed 3 years ago

yyibin commented 4 years ago

We use this code to connect to HA Redis, create/subscribe a PUBSUB channel and read out the published message: local sub = assert(redis_conf.redis_connector:connect()) local _, err = sub:subscribe(redis_conf.channel) ... local bytes, error = sub:read_reply()

When testing on a HA Redis failover scenario, the existing PUBSUB channels are gone when the master Redis goes down. We were expecting the PUBSUB channel with the same name would be created and subscribed automatically by lua-resty-redis-connector in the newly promoted master node, but it didn't happen.

Is this something lua-resty-redis-connector handles? Or our code needs to explicitly handle this failure scenario?

Thanks.

pintsized commented 3 years ago

Hi, sorry for taking forever to respond. Yes, this is something your code will need to handle. The connector's job is to make it easier to you to establish connections, nothing more.