-
Notifications
You must be signed in to change notification settings - Fork 330
Change redisselect to use the same DBConnector object to subscribe to multiple patterns #1079
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Vivek Reddy <[email protected]>
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
@qiluo-msft This is the PR which was created based on the discussion with Vivek and Sudharsan (pubsub improvement) Please review when you have time. Thank you |
| self.pubsub = self.get_redis_client(self.db_name).pubsub() | ||
|
|
||
| def subscribe(self, table, handler, fire_init_data=False): | ||
| self._ensure_pubsub() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one pitfall in this solution. The redis connections are not thread safe, so each connection should be used inside each thread only. If multiple thread calling subscribe, they will share the same pubsub, which will not work.
you may consider thread local variables if you really want to achieve the optimization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @qiluo-msft , Is the existing solution thread safe? And would there be instances where the implementation is done in this way (with multi-thread subscribe calls)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The redis connections are not thread safe
|
/azpw run |
|
/AzurePipelines run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Update pubsub class to use the same dbconnector class and use it for ConfigDbConnector listen, so that it can subscribe to multiple patterns at the same time, thereby causing it to be used only once
Test results