You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 9, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: docs/pipelines.rst
+15-8Lines changed: 15 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,7 @@ An `ASK` error means the slot is only partially migrated and that the client can
38
38
The philosophy on pipelines
39
39
---------------------------
40
40
41
-
After playing around with pipelines and thinking about possible solutions that could be used in a cluster setting this document will describe how pipelines work, strengths and weaknesses with the implementation that was chosen.
41
+
After playing around with pipelines and thinking about possible solutions that could be used in a cluster setting this document will describe how pipelines work, strengths and weaknesses of the implementation that was chosen.
42
42
43
43
Why can't we reuse the pipeline code in `redis-py`? In short it is almost the same reason why code from the normal redis client can't be reused in a cluster environment and that is because of the slots system. Redis cluster consist of a number of slots that is distributed across a number of servers and each key belongs in one of these slots.
44
44
@@ -62,9 +62,16 @@ Consider the following example. Create a pipeline and issue 6 commands `A`, `B`,
62
62
63
63
If we look back at the order we executed the commands we get `[A, F]` for the first node and `[B, E, C, D]` for the second node. At first glance this looks like it is out of order because command `E` is executed before `C` & `D`. Why is this not matter? Because no multi key operations can be done in a pipeline, we only have to care the execution order is correct for each slot and in this case it was because `B` & `E` belongs to the same slot and `C` & `D` belongs to the same slot. There should be no possible way to corrupt any data between slots if multi key commands are blocked by the code.
64
64
65
-
What is good with this pipeline solution? First we can actually have a pipeline solution that will work in most cases with few commands blocked (only multi key commands). Secondly we can run it in parralel to increase the performance of the pipeline even further, making the benefits even greater.
65
+
What is good with this pipeline solution? First we can actually have a pipeline solution that will work in most cases with few commands blocked (only multi key commands). Secondly we can run it in parallel to increase the performance of the pipeline even further, making the benefits even greater.
66
66
67
67
68
+
Packing Commands
69
+
----------------
70
+
71
+
When issuing only a single command, there is only one network round trip to be made. But what if you issue 100 pipelined commands? In a single-instance redis configuration, you still only need to make one network hop. The commands are packed into a single request and the server responds with all the data for those requests in a single response. But with redis cluster, those keys could be spread out over many different nodes.
72
+
73
+
The client is responsible for figuring out which commands map to which nodes. Let's say for example that your 100 pipelined commands need to route to 3 different nodes? The first thing the client does is break out the commands that go to each node, so it only has 3 network requests to make instead of 100.
74
+
68
75
69
76
Transactions and WATCH
70
77
----------------------
@@ -135,7 +142,7 @@ This section will describe different types of pipeline solutions. It will list t
135
142
Suggestion one
136
143
**************
137
144
138
-
Simple but yet sequential pipeline. This solution acts more like an interface for the already existing pipeline implementation and only provides a simple backwards compatible interface to ensure that code that sexists still will work withouth any major modifications. The good this with this implementation is that because all commands is runned in sequence it will handle `MOVED` or `ASK` redirections very good and withouth any problems. The major downside to this solution is that no commands is ever batched and runned in parralell and thus you do not get any major performance boost from this approach. Other plus is that execution order is preserved across the entire cluster but a major downside is that thte commands is no longer atomic on the cluster scale because they are sent in multiple commands to different nodes.
145
+
Simple but yet sequential pipeline. This solution acts more like an interface for the already existing pipeline implementation and only provides a simple backwards compatible interface to ensure that code that sexists still will work withouth any major modifications. The good this with this implementation is that because all commands is runned in sequence it will handle `MOVED` or `ASK` redirections very good and withouth any problems. The major downside to this solution is that no command is ever batched and ran in parallel and thus you do not get any major performance boost from this approach. Other plus is that execution order is preserved across the entire cluster but a major downside is that thte commands is no longer atomic on the cluster scale because they are sent in multiple commands to different nodes.
139
146
140
147
**Good**
141
148
@@ -151,24 +158,24 @@ Simple but yet sequential pipeline. This solution acts more like an interface fo
151
158
Suggestion two
152
159
**************
153
160
154
-
Current pipeline implementation. This implementation is rather good and works well because it combines the existing pipeline interface and functionality and it also provides a basic handling of `ASK` or `MOVED` errors inside the client. One major downside to this is that execution order is not preserved across the cluster. Altho the execution order is somewhat broken if you look at the entire cluster level becuase commands can be splitted so that cmd1, cmd3, cmd5 get sent to one server and cmd2, cmd4 gets sent to another server. The order is then broken globally but locally for each server it is preserved and maintained correctly. On the other hand i guess that there can't be any commands that can affect different hashslots within the same command so it maybe do not really matter if the execution order is not correct because for each slot/key the order is valid.
155
-
There might be some issues with rebuilding the correct response ordering from the scattered data because each command might be in different sub pipelines. But i think that our current code still handles this correctly. I think i have to figure out some wierd case where the execution order acctually matters. There might be some issues with the nonsupported mget/mset commands that acctually performs different sub commands then it currently supports.
161
+
Current pipeline implementation. This implementation is rather good and works well because it combines the existing pipeline interface and functionality and it also provides a basic handling of `ASK` or `MOVED` errors inside the client. One major downside to this is that execution order is not preserved across the cluster. Although the execution order is somewhat broken if you look at the entire cluster level because commands can be split so that cmd1, cmd3, cmd5 get sent to one server and cmd2, cmd4 gets sent to another server. The order is then broken globally but locally for each server it is preserved and maintained correctly. On the other hand I guess that there can't be any commands that can affect different hashslots within the same command so maybe it really doesn't matter if the execution order is not correct because for each slot/key the order is valid.
162
+
There might be some issues with rebuilding the correct response ordering from the scattered data because each command might be in different sub pipelines. But I think that our current code still handles this correctly. I think I have to figure out some weird case where the execution order actually matters. There might be some issues with the nonsupported mget/mset commands that acctually performs different sub commands then it currently supports.
156
163
157
164
**Good**
158
165
159
166
- Sequential execution per node
160
167
161
168
**Bad**
162
169
163
-
- Not sequential execution on the entire pipeline
170
+
- Non sequential execution on the entire pipeline
164
171
- Medium difficult `ASK` or `MOVED` handling
165
172
166
173
167
174
168
175
Suggestion three
169
176
****************
170
177
171
-
There is a even simpler form of pipelines that can be made where all commands is supported as long as they conform to the same hashslot because redis supports that mode of operation. The good thing with this is that sinc all keys must belong to the same slot there can't be very few `ASK` or `MOVED` errors that happens and if they happen they will be very easy to handle because the entire pipeline is kinda atomic because you talk to the same server and only 1 server. There can't be any multiple server communication happening.
178
+
There is a even simpler form of pipelines that can be made where all commands is supported as long as they conform to the same hashslot because REDIS supports that mode of operation. The good thing with this is that since all keys must belong to the same slot there can't be very few `ASK` or `MOVED` errors that happens and if they happen they will be very easy to handle because the entire pipeline is kinda atomic because you talk to the same server and only 1 server. There can't be any multiple server communication happening.
172
179
173
180
**Good**
174
181
@@ -184,7 +191,7 @@ There is a even simpler form of pipelines that can be made where all commands is
184
191
Suggestion four
185
192
**************
186
193
187
-
One other solution is the 2 step commit solution where you send for each server 2 batches of commands. The first command should somehow establish that each keyslot is in the correct state and able to handle the data. After the client have recieved OK from all nodes that all data slots is good to use then it will acctually send the real pipeline with all data and commands. The big problem with this approach is that ther eis a gap between the checking of the slots and the acctual sending of the data where things can happen to the already established slots setup. But at the same time there is no possibility of merging these 2 steps because if step 2 is automatically runned if step 1 is Ok then the pipeline for the first node that will fail will fail but for the other nodes it will suceed but when it should not because if one command gets `ASK` or `MOVED` redirection then all pipeline objects must be rebuilt to match the new specs/setup and then reissued by the client. The major advantage of this solution is that if you have total controll of the redis server and do controlled upgrades when no clients is talking to the server then it can acctually work really well because there is no possibility that `ASK` or `MOVED` will triggered by migrations in between the 2 batches.
194
+
One other solution is the 2 step commit solution where you send for each server 2 batches of commands. The first command should somehow establish that each keyslot is in the correct state and able to handle the data. After the client have recieved OK from all nodes that all data slots is good to use then it will acctually send the real pipeline with all data and commands. The big problem with this approach is that ther eis a gap between the checking of the slots and the acctual sending of the data where things can happen to the already established slots setup. But at the same time there is no possibility of merging these 2 steps because if step 2 is automatically runned if step 1 is Ok then the pipeline for the first node that will fail will fail but for the other nodes it will suceed but when it should not because if one command gets `ASK` or `MOVED` redirection then all pipeline objects must be rebuilt to match the new specs/setup and then reissued by the client. The major advantage of this solution is that if you have total controll of the redis server and do controlled upgrades when no clients is talking to the server then it can actually work really well because there is no possibility that `ASK` or `MOVED` will triggered by migrations in between the 2 batches.
Copy file name to clipboardExpand all lines: docs/release-notes.rst
+21-1Lines changed: 21 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,26 @@
1
1
Release Notes
2
2
=============
3
3
4
+
1.3.5 (July 22, 2018)
5
+
--------------
6
+
7
+
* Add Redis 4 compatability fix to CLUSTER NODES command (See issue #217)
8
+
* Fixed bug with command "CLUSTER GETKEYSINSLOT" that was throwing exceptions
9
+
* Added new methods cluster_get_keys_in_slot() to client
10
+
* Fixed bug with `StrictRedisCluster.from_url` that was ignoring the `readonly_mode` parameter
11
+
* NodeManager will now ignore nodes showing cluster errors when initializing the cluster
12
+
* Fix bug where RedisCluster wouldn't refresh the cluster table when executing commands on specific nodes
13
+
* Add redis 5.0 to travis-ci tests
14
+
* Change default redis version from 3.0.7 to 4.0.10
15
+
* Increase accepted ranges of dependencies specefied in dev-requirements.txt
16
+
* Several major and minor documentation updates and tweaks
17
+
* Add example script "from_url_password_protected.py"
18
+
* command "CLUSTER GETKEYSINSLOT" is now returned as a list and not int
19
+
* Improve support for ssl connections
20
+
* Retry on Timeout errors when doing cluster discovery
21
+
* Added new error class "MasterDownError"
22
+
* Updated requirements for dependency of redis-py to latest version
23
+
4
24
1.3.4 (Mar 5, 2017)
5
25
-------------------
6
26
@@ -79,7 +99,7 @@ Release Notes
79
99
* Implement all "CLUSTER ..." commands as methods in the client class
80
100
* Client now follows the service side setting 'cluster-require-full-coverage=yes/no' (baranbartu)
81
101
* Change the pubsub implementation (PUBLISH/SUBSCRIBE commands) from using one single node to now determine the hashslot for the channel name and use that to connect to
82
-
a node in the cluster. Other clients that do not use this pattern will not be fully compatible with this client. Known limitations is pattern
102
+
a node in the cluster. Other clients that do not use this pattern will not be fully compatible with this client. Known limitations is pattern
83
103
subscription that do not work properly because a pattern can't know all the possible channel names in advance.
84
104
* Convert all docs to ReadTheDocs
85
105
* Rework connection pool logic to be more similar to redis-py. This also fixes an issue with pubsub and that connections
Copy file name to clipboardExpand all lines: docs/threads.rst
-9Lines changed: 0 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -13,15 +13,6 @@ The advantage to this design is that a smart client can communicate with the clu
13
13
14
14
15
15
16
-
Packing Commands
17
-
----------------
18
-
19
-
When issuing only a single command, there is only one network round trip to be made. But what if you issue 100 pipelined commands? In a single-instance redis configuration, you still only need to make one network hop. The commands are packed into a single request and the server responds with all the data for those requests in a single response. But with redis cluster, those keys could be spread out over many different nodes.
20
-
21
-
The client is responsible for figuring out which commands map to which nodes. Let's say for example that your 100 pipelined commands need to route to 3 different nodes? The first thing the client does is break out the commands that go to each node, so it only has 3 network requests to make instead of 100.
Copy file name to clipboardExpand all lines: docs/upgrading.rst
+6-1Lines changed: 6 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -3,11 +3,16 @@ Upgrading redis-py-cluster
3
3
4
4
This document describes what must be done when upgrading between different versions to ensure that code still works.
5
5
6
+
1.3.2 --> Next Release
7
+
----------------------
8
+
9
+
If you created the `StrictRedisCluster` (or `RedisCluster`) instance via the `from_url` method and were passing `readonly_mode` to it, the connection pool created will now properly allow selecting read-only slaves from the pool. Previously it always used master nodes only, even in the case of `readonly_mode=True`. Make sure your code don't attempt any write commands over connections with `readonly_mode=True`.
10
+
6
11
7
12
1.3.1 --> 1.3.2
8
13
---------------
9
14
10
-
If your redis instance is configured to not have the `CONFIG ...` comannds enabled due to security reasons you need to pass this into the client object `skip_full_coverage_check=True`. Benefits is that the client class no longer requires the `CONFIG ...` commands to be enabled on the server. Downsides is that you can't use the option in your redis server and still use the same feature in this client.
15
+
If your redis instance is configured to not have the `CONFIG ...` commands enabled due to security reasons you need to pass this into the client object `skip_full_coverage_check=True`. Benefits is that the client class no longer requires the `CONFIG ...` commands to be enabled on the server. Downsides is that you can't use the option in your redis server and still use the same feature in this client.
0 commit comments