When the command info cannot be retrieved, Go-Redis should return the correct key position for the command, or an appropriate error. The expected behavior is for the library to handle the ZADD command properly without requiring a preceding PING command.
Current Behavior
In Go-Redis v8, if command info cannot be retrieved, the library defaults to returning an index of 0 (which is the command name, in this case, ZADD). This behavior is incorrect. However, Go-Redis v9 has fixed this issue.
Additionally, when used with redis-coordinator (custom Redis-Proxy), the client fails to retrieve command info. The issue is resolved if a PING command is issued first, which forces the client to call the Redis server and retrieve the info correctly. This explains why adding a PING command before executing ZADD in Go-Redis v8 avoids the error.
Possible Solution
The fix for this issue has already been implemented in Go-Redis v9. One possible solution is to upgrade to v9, which return index 1 instead of index 0.
Another workaround for Go-Redis v8 users is to ensure that the PING command is called before operations like ZADD to avoid the error.
Steps to Reproduce
Set up a Redis cluster using a redis-coordinator that does not support the COMMAND command.
Initialize a Redis cluster client using Go-Redis v8.
Perform a ZADD operation without calling PING first.
Observe the incorrect behavior where ZADD fails due to the wrong index being returned.
Now, add the PING command before the ZADD and see that the issue is resolved.
Context (Environment)
This issue affects environments using Redis with redis-coordinator in Go-Redis v8. In this setup, the lack of support for the COMMAND command in the coordinator causes problems when the client fails to retrieve the command info, resulting in incorrect behavior.
By issuing a PING command first, the client calls the Redis server and retrieves the necessary info, avoiding the error.
Detailed Description
Go-Redis v8 defaults to returning index 0 when command info is not available, which is incorrect for some Redis commands like ZADD. In scenarios where redis-coordinator is used and doesn't support the COMMAND command, the client fails to get command info unless a PING is sent first, which mitigates the issue.
This bug has been fixed in Go-Redis v9, where the correct index is returned even when command info is not available.
Possible Implementation
Encourage users to upgrade to Go-Redis v9, which has a proper fix.
For Go-Redis v8, document that users should issue a PING before commands like ZADD to avoid the issue, or explore a backport of the v9 fix if necessary.
Expected Behavior
When the command info cannot be retrieved, Go-Redis should return the correct key position for the command, or an appropriate error. The expected behavior is for the library to handle the
ZADD
command properly without requiring a precedingPING
command.Current Behavior
In Go-Redis v8, if command info cannot be retrieved, the library defaults to returning an index of 0 (which is the command name, in this case,
ZADD
). This behavior is incorrect. However, Go-Redis v9 has fixed this issue.Additionally, when used with
redis-coordinator
(custom Redis-Proxy), the client fails to retrieve command info. The issue is resolved if aPING
command is issued first, which forces the client to call the Redis server and retrieve the info correctly. This explains why adding aPING
command before executingZADD
in Go-Redis v8 avoids the error.Possible Solution
PING
command is called before operations likeZADD
to avoid the error.Steps to Reproduce
redis-coordinator
that does not support theCOMMAND
command.ZADD
operation without callingPING
first.ZADD
fails due to the wrong index being returned.PING
command before theZADD
and see that the issue is resolved.Context (Environment)
This issue affects environments using Redis with
redis-coordinator
in Go-Redis v8. In this setup, the lack of support for theCOMMAND
command in the coordinator causes problems when the client fails to retrieve the command info, resulting in incorrect behavior.By issuing a
PING
command first, the client calls the Redis server and retrieves the necessary info, avoiding the error.Detailed Description
Go-Redis v8 defaults to returning index 0 when command info is not available, which is incorrect for some Redis commands like
ZADD
. In scenarios whereredis-coordinator
is used and doesn't support theCOMMAND
command, the client fails to get command info unless aPING
is sent first, which mitigates the issue.This bug has been fixed in Go-Redis v9, where the correct index is returned even when command info is not available.
Possible Implementation
PING
before commands likeZADD
to avoid the issue, or explore a backport of the v9 fix if necessary.Go-Redis V9
https://github.com/redis/go-redis/blob/1da50b33ef44c54143b194edcba664d7503b8fc9/command.go#L78-L99
Go-Redis V8
https://github.com/redis/go-redis/blob/cae67723092cac2cb441bc87044ab9edacb2484d/command.go#L62-L87