Skip to content

Conversation

starplanet
Copy link

  1. fix redis worker hang when redis connection is lost or redis server is restarted. When redis server is restarted, the collect thread in original service streamer will exit;

  2. fix redis subscribe channel lost when redis subscribe connection receive no message for a long time. Add health check for get_messsage api.

  3. remove the requirement that redis server subscribes all channels.

return pickle.loads(message["data"])
except RedisError as e:
logger.warning('recv_response: redis error occurs in get_message, {}', str(e))
self._setup() # 重新订阅
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be an issue here. self._setup() fails when redis server is stopped, but when redis server restarts, this self._setup() usually will not get executed because the above try: entry now returns with no error.

Suggested change
self._setup() # 重新订阅
while True:
try:
self._redis.ping()
self._setup() # 重新订阅
break
except RedisError as e:
time.sleep(0.2)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find that completely removal of the self._setup() part in the error handling step also works. It looks like redis-py recovers the connection and the previously subscribed channel after the failure.
If the _setup() is executed and erred during the redis-server's downtime, then redis-py cannot recover previous subscription anymore.

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

Successfully merging this pull request may close these issues.

3 participants