Skip to content

Commit dd5a0b2

Browse files
committed
update due to multi-slot requests support
Signed-off-by: BoazBD <[email protected]>
1 parent e93c0a4 commit dd5a0b2

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

python/python/glide/async_commands/server_modules/json.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,12 @@ async def mget(
213213
Retrieves the JSON values at the specified `path` stored at multiple `keys`.
214214
215215
Note:
216-
When in cluster mode, the command may route to multiple nodes when `keys` map to different hash slots.
216+
In cluster mode, if keys in `keyValueMap` map to different hash slots, the command
217+
will be split across these slots and executed separately for each. This means the command
218+
is atomic only at the slot level. If one or more slot-specific requests fail, the entire
219+
call will return the first encountered error, even though some requests may have succeeded
220+
while others did not. If this behavior impacts your application logic, consider splitting
221+
the request into sub-requests per slot to ensure atomicity.
217222
Args:
218223
client (TGlideClient): The Redis client to execute the command.
219224
keys (List[TEncodable]): A list of keys for the JSON documents.
@@ -244,7 +249,7 @@ async def mget(
244249
if path:
245250
args.append(path)
246251

247-
return cast(List[Optional[bytes]], await client.custom_command(args))
252+
return cast(TJsonResponse[Optional[bytes]], await client.custom_command(args))
248253

249254

250255
async def arrappend(

python/python/tests/tests_server_modules/test_json.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,8 @@ async def test_json_get_formatting(self, glide_client: TGlideClient):
165165
@pytest.mark.parametrize("cluster_mode", [True, False])
166166
@pytest.mark.parametrize("protocol", [ProtocolVersion.RESP2, ProtocolVersion.RESP3])
167167
async def test_json_mget(self, glide_client: TGlideClient):
168-
key = get_random_string(5)
169-
key1 = f"{{{key}}}1"
170-
key2 = f"{{{key}}}2"
171-
# The prefix ensures that both keys hash to the same slot
168+
key1 = get_random_string(5)
169+
key2 = get_random_string(5)
172170

173171
json1_value = {"a": 1.0, "b": {"a": 1, "b": 2.5, "c": True}}
174172
json2_value = {"a": 3.0, "b": {"a": 1, "b": 4}}

0 commit comments

Comments
 (0)