[GH-ISSUE #794] [FEATURE REQUEST] redis client version compatibility #390

Closed
opened 2026-03-02 05:20:52 +03:00 by kerem · 9 comments
Owner

Originally created by @Jeremy-Run on GitHub (Dec 6, 2023).
Original GitHub issue: https://github.com/hibiken/asynq/issues/794

Originally assigned to: @hibiken on GitHub.

Background:
Our project uses asynq-v0.24.0, which was recently upgraded to asynq-v0.24.1 .
The client generated by go-redis/v8 used in the project.

After upgrading, I found that this part of the code failed to execute:

// NewClient returns a new Client instance given a redis connection option.
func NewClient(r RedisConnOpt) *Client {
	c, ok := r.MakeRedisClient().(redis.UniversalClient)
	if !ok {
		panic(fmt.Sprintf("asynq: unsupported RedisConnOpt type %T", r))
	}
	return &Client{broker: rdb.NewRDB(c)}
}

The investigation revealed that the cause of this problem is that the UniversalClient of go-redis/v9 is different from the UniversalClient of go-redis/v8.

Suggestion:
Can you give us a hint as to what version of redis client should be uploaded? Or be compatible with several new versions of go-redis?

Originally created by @Jeremy-Run on GitHub (Dec 6, 2023). Original GitHub issue: https://github.com/hibiken/asynq/issues/794 Originally assigned to: @hibiken on GitHub. Background: Our project uses asynq-v0.24.0, which was recently upgraded to asynq-v0.24.1 . The client generated by go-redis/v8 used in the project. After upgrading, I found that this part of the code failed to execute: ``` // NewClient returns a new Client instance given a redis connection option. func NewClient(r RedisConnOpt) *Client { c, ok := r.MakeRedisClient().(redis.UniversalClient) if !ok { panic(fmt.Sprintf("asynq: unsupported RedisConnOpt type %T", r)) } return &Client{broker: rdb.NewRDB(c)} } ``` The investigation revealed that the cause of this problem is that the UniversalClient of go-redis/v9 is different from the UniversalClient of go-redis/v8. Suggestion: Can you give us a hint as to what version of redis client should be uploaded? Or be compatible with several new versions of go-redis?
kerem 2026-03-02 05:20:52 +03:00
Author
Owner

@kamikazechaser commented on GitHub (Dec 6, 2023):

I don't fully understand your question. Asynq uses go-redis/v9. Afaik, the tests pass and everything works fine.

However if you are reusing a go-redis connection for asynq, you need to set it up correctly.

<!-- gh-comment-id:1842721837 --> @kamikazechaser commented on GitHub (Dec 6, 2023): I don't fully understand your question. Asynq uses go-redis/v9. Afaik, the tests pass and everything works fine. However if you are reusing a go-redis connection for asynq, you need to set it up correctly.
Author
Owner

@Jeremy-Run commented on GitHub (Dec 6, 2023):

@kamikazechaser
Thank you for your reply!
Let me improve my question:
In our project, this will report an error when using NewClient(r RedisConnOpt). The reason for the error is that r.MakeRedisClient() returns a go-redis/v8 client, which cannot be converted into redis.UniversalClient in go-redis/v9.

<!-- gh-comment-id:1842736922 --> @Jeremy-Run commented on GitHub (Dec 6, 2023): @kamikazechaser Thank you for your reply! Let me improve my question: In our project, this will report an error when using NewClient(r RedisConnOpt). The reason for the error is that r.MakeRedisClient() returns a go-redis/v8 client, which cannot be converted into redis.UniversalClient in go-redis/v9.
Author
Owner

@kamikazechaser commented on GitHub (Dec 6, 2023):

Could you additionally post the code on your end to reproduce this issue.

<!-- gh-comment-id:1843120453 --> @kamikazechaser commented on GitHub (Dec 6, 2023): Could you additionally post the code on your end to reproduce this issue.
Author
Owner

@kamikazechaser commented on GitHub (Dec 6, 2023):

Possibly related to #790

<!-- gh-comment-id:1843131255 --> @kamikazechaser commented on GitHub (Dec 6, 2023): Possibly related to #790
Author
Owner

@Jeremy-Run commented on GitHub (Dec 7, 2023):

This panic is inevitable.
This is my pseudo-code:

package main

import (
	"github.com/hibiken/asynq"  // v0.24.1 
	"github.com/go-redis/redis/v8"
)

type XRDS struct {
	*redis.Client
}

func (xrds *XRDS) MakeRedisClient() interface{} {
	return xrds
}

func NewRedisClient() *XRDS {
	c := redis.NewFailoverClient(&redis.FailoverOptions{
		MasterName:    "mymaster",
		SentinelAddrs: []string{"x.x.x.x:16379", "x.x.x.x:16379", "x.x.x.x:16379"},
		Password:      "xxxxxx",
		DB:            1,
	})
	return &XRDS{Client: c}
}

func main() {
	_ = asynq.NewClient(NewRedisClient())
}
<!-- gh-comment-id:1844779990 --> @Jeremy-Run commented on GitHub (Dec 7, 2023): This panic is inevitable. This is my pseudo-code: ``` package main import ( "github.com/hibiken/asynq" // v0.24.1 "github.com/go-redis/redis/v8" ) type XRDS struct { *redis.Client } func (xrds *XRDS) MakeRedisClient() interface{} { return xrds } func NewRedisClient() *XRDS { c := redis.NewFailoverClient(&redis.FailoverOptions{ MasterName: "mymaster", SentinelAddrs: []string{"x.x.x.x:16379", "x.x.x.x:16379", "x.x.x.x:16379"}, Password: "xxxxxx", DB: 1, }) return &XRDS{Client: c} } func main() { _ = asynq.NewClient(NewRedisClient()) } ```
Author
Owner

@kamikazechaser commented on GitHub (Dec 7, 2023):

"github.com/go-redis/redis/v8"

Use go-redis/v9 with v0.24.1 and let me know if the issue still persists. I see that you are not using the x module which is problematic right now.

<!-- gh-comment-id:1844787717 --> @kamikazechaser commented on GitHub (Dec 7, 2023): > "github.com/go-redis/redis/v8" Use go-redis/v9 with v0.24.1 and let me know if the issue still persists. I see that you are not using the `x` module which is problematic right now.
Author
Owner

@Jeremy-Run commented on GitHub (Dec 7, 2023):

Yes, we can't go wrong with go-redis/v9.
What I want to ask is, does asynq need to support multiple go-redis versions?

<!-- gh-comment-id:1844861149 --> @Jeremy-Run commented on GitHub (Dec 7, 2023): Yes, we can't go wrong with go-redis/v9. What I want to ask is, does asynq need to support multiple go-redis versions?
Author
Owner

@kamikazechaser commented on GitHub (Dec 7, 2023):

What I want to ask is, does asynq need to support multiple go-redis versions?

No. We want to stick with v9 only. You can track some changes on the sohail/go-update branch which removes the last mention of go-redis/v8 from the x module.

<!-- gh-comment-id:1844874763 --> @kamikazechaser commented on GitHub (Dec 7, 2023): > What I want to ask is, does asynq need to support multiple go-redis versions? No. We want to stick with v9 only. You can track some changes on the [sohail/go-update](https://github.com/hibiken/asynq/tree/sohail/go-update) branch which removes the last mention of go-redis/v8 from the x module.
Author
Owner

@Jeremy-Run commented on GitHub (Dec 7, 2023):

Well, thank you for your answer.

<!-- gh-comment-id:1844878470 --> @Jeremy-Run commented on GitHub (Dec 7, 2023): Well, thank you for your answer.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/asynq#390
No description provided.