Skip to content

Potential Command Duplication in _send_command_parse_response Retry Mechanism #3554

Closed
@ManelCoutinhoSensei

Description

@ManelCoutinhoSensei

Hi there,

I have a conceptual problem with how the _send_command_parse_response is being grouped:

redis-py/redis/client.py

Lines 590 to 595 in ea01a30

def _send_command_parse_response(self, conn, command_name, *args, **options):
"""
Send a command and parse the response
"""
conn.send_command(*args, **options)
return self.parse_response(conn, command_name, **options)

My issue is that this method is called inside a retry mechanism:

redis-py/redis/client.py

Lines 623 to 628 in ea01a30

return conn.retry.call_with_retry(
lambda: self._send_command_parse_response(
conn, command_name, *args, **options
),
lambda error: self._disconnect_raise(conn, error),
)

Which means that if the Redis container goes down after send_command and before parse_response, the entire _send_command_parse_response will be retried. This means that any command with side effects (such as XADD) could be executed twice instead of just once, leading to unintended duplication.

Would love to hear thoughts on potential fixes for this issue. Let me know if you need any additional details!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions