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

race condition in __wait_for_db_init() ? #13

Open
jipanyang opened this issue Sep 24, 2017 · 0 comments
Open

race condition in __wait_for_db_init() ? #13

jipanyang opened this issue Sep 24, 2017 · 0 comments
Labels

Comments

@jipanyang
Copy link

Based on the description in https://redis.io/topics/notifications:
"
Because Redis Pub/Sub is fire and forget currently there is no way to use this feature if your application demands reliable notification of events, that is, if your Pub/Sub client disconnects, and reconnects later, all the events delivered during the time the client was disconnected are lost.
"
It looks to me there is possibility the INIT_INDICATOR is set between client.get() and pubsub.psubscribe(pattern), the notification might get missed and pubsub.listen() will be blocked there, unless client buffers all notification from the moment of client.pubsub()

def __wait_for_db_init(self):
    client = self.redis_clients[self.CONFIG_DB]
    pubsub = client.pubsub()
    initialized = client.get(self.INIT_INDICATOR)
    if not initialized:
        pattern = "__keyspace@{}__:{}".format(self.db_map[self.CONFIG_DB]['db'], self.INIT_INDICATOR)
        pubsub.psubscribe(pattern)
        for item in pubsub.listen():
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants