readonly mode not execute command on slave node
See original GitHub issueI set readonly_mode=True to test the readonly mode. And print the node which realy execute command. But whether readonly_mode is True or False the node server_type is all master.
from rediscluster import RedisCluster
def main():
startup_nodes = [{"host": "", "port": ""}]
rc = RedisCluster(startup_nodes=startup_nodes, decode_responses=True, readonly_mode=True)
print(rc.set('foo', 'bar'))
print(rc.get('foo'))
if __name__ == "__main__":
main()
I print the node in client.py to get node info.
@clusterdown_wrapper
def execute_command(self, *args, **kwargs):
"""
Send a command to a node in the cluster
"""
....
else:
if self.refresh_table_asap:
# MOVED
node = self.connection_pool.get_master_node_by_slot(slot)
else:
node = self.connection_pool.get_node_by_slot(slot, self.read_from_replicas and (command in self.READ_COMMANDS))
is_read_replica = node['server_type'] == 'slave'
print(node)
r = self.connection_pool.get_connection_by_node(node)
....
The print is :
{'host': '', 'port': , 'name': '', 'server_type': 'master'}
True
{'host': '', 'port': , 'name': '', 'server_type': 'master'}
bar
I consider is because of the partial get node.
if self.refresh_table_asap:
# MOVED
node = self.connection_pool.get_master_node_by_slot(slot)
else:
node = self.connection_pool.get_node_by_slot(slot, self.read_from_replicas and (command in self.READ_COMMANDS))
is_read_replica = node['server_type'] == 'slave'
r = self.connection_pool.get_connection_by_node(node)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:5 (2 by maintainers)
Top Results From Across the Web
(lettuce) READONLY You can't write against a read only slave
Whenever the service is deployed, several docker nodes will appear ERROR: READONLY You can't write against a read only slave. lettuce ...
Read more >Readonly mode — redis-py-cluster 2.1.3 documentation
By default, Redis Cluster always returns MOVE redirection response on accessing slave node. You can overcome this limitation [for scaling read with READONLY...
Read more >READONLY - Redis
READONLY tells a Redis Cluster replica node that the client is willing to read possibly stale data and is not interested in running...
Read more >Configure repository - Alfresco Docs
To set Alfresco to read-only mode, use one of the following methods: Using the alfresco-global.properties file; Using a JMX client such as JConsole....
Read more >Readwritesplit - MariaDB Knowledge Base
The readwritesplit router is designed to increase the read-only processing capability of a cluster while maintaining consistency.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The two different connection pools will get a makeover in 3.0.0
@ididid8 I did some digging into this issue, what i figured out is that there is two different connectionpools implemented that is controlled and activated by two different flags. What it seems like is that the flag you are using right now
readonly_mode=True
is using a broken implementation of READONLY mode. What is working tho is the following code snippet where i modified your exampleread_from_replicas=True
activates a working connectionpool that will utilize READONLY correctly. When i ran the script above it loadbalanced the GET commands about equally between the master and the slave nodes to which the slot belonged to. No it do not send all read commands to the slaves, but it loadbalances them equally across all nodes at least. Both of these connection pools needs to be merged into a single solution, but right now they will remain as is until i can sort that out and i reccommend that you useread_from_replicas=True
to fullfill your need.