go-redis/redis · error

redis: AutoPipeline is not supported by Ring

Error message

redis: AutoPipeline is not supported by Ring

What it means

ErrRingAutoPipelineUnsupported is returned by Ring.AutoPipeline, AutoPipelineWithOptions, AsyncAutoPipeline, and AsyncAutoPipelineWithOptions. Autopipelining is implemented for Client and ClusterClient but not for Ring; the methods exist only to satisfy the UniversalClient interface and fail explicitly so callers don't get silent no-ops. Check with errors.Is(err, redis.ErrRingAutoPipelineUnsupported).

Source

Thrown at ring.go:872

func (c *Ring) Pipelined(ctx context.Context, fn func(Pipeliner) error) ([]Cmder, error) {
	return c.Pipeline().Pipelined(ctx, fn)
}

func (c *Ring) Pipeline() Pipeliner {
	pipe := Pipeline{
		exec: pipelineExecer(c.processPipelineHook),
	}
	pipe.init()
	return &pipe
}

// ErrRingAutoPipelineUnsupported is returned by Ring's AutoPipeline /
// AsyncAutoPipeline (and their WithOptions forms); check for it with
// errors.Is. Autopipelining is not implemented for Ring; use the per-shard
// clients or a ClusterClient. Ring is part of the UniversalClient
// interface, so these methods exist to satisfy it and fail explicitly rather
// than being silently absent.
var ErrRingAutoPipelineUnsupported = errors.New("redis: AutoPipeline is not supported by Ring")

// AutoPipeline is not supported by Ring; it returns ErrRingAutoPipelineUnsupported.
func (c *Ring) AutoPipeline() (*AutoPipeliner, error) {
	return c.AutoPipelineWithOptions(nil)
}

// AutoPipelineWithOptions is not supported by Ring; it returns ErrRingAutoPipelineUnsupported.
func (c *Ring) AutoPipelineWithOptions(config *AutoPipelineOptions) (*AutoPipeliner, error) {
	return nil, ErrRingAutoPipelineUnsupported
}

// AsyncAutoPipeline is not supported by Ring; it returns ErrRingAutoPipelineUnsupported.
func (c *Ring) AsyncAutoPipeline() (*AutoPipeliner, error) {
	return c.AsyncAutoPipelineWithOptions(nil)
}

// AsyncAutoPipelineWithOptions is not supported by Ring; it returns ErrRingAutoPipelineUnsupported.
func (c *Ring) AsyncAutoPipelineWithOptions(config *AutoPipelineOptions) (*AutoPipeliner, error) {

View on GitHub (pinned to 36d97525cd)

Solutions

  1. Use a ClusterClient instead of a Ring if you need autopipelining with multiple nodes (cluster protocol is supported).
  2. Use Ring's regular Pipeline() / Pipelined() for manual batching instead of autopipelining.
  3. Access the underlying per-shard Clients directly and enable autopipelining on each one.

Example fix

// before — Ring does not support autopipelining
ring := redis.NewRing(&redis.RingOptions{Addrs: ...})
ap, err := ring.AutoPipeline() // err = ErrRingAutoPipelineUnsupported

// after — use manual pipelining on the Ring
pipe := ring.Pipeline()
pipe.Set(ctx, "k", "v", 0)
cmds, err := pipe.Exec(ctx)

// or switch to ClusterClient if you want autopipelining
cluster := redis.NewClusterClient(&redis.ClusterOptions{Addrs: ...})
ap, err := cluster.AutoPipeline()
Defensive patterns

Strategy: validation

Validate before calling

func supportsAutoPipeline(c redis.UniversalClient) bool {
    switch c.(type) {
    case *redis.Client, *redis.ClusterClient:
        return true
    }
    return false // *redis.Ring returns ErrRingAutoPipelineUnsupported
}

Type guard

var _ redis.UniversalClient = (*redis.Ring)(nil)

func isRing(c redis.UniversalClient) bool {
    _, ok := c.(*redis.Ring)
    return ok
}

Try / catch

ap, err := c.AutoPipeline()
if err != nil {
    if errors.Is(err, redis.ErrRingAutoPipelineUnsupported) {
        // fall back to manual Pipeline() or switch to ClusterClient
    }
}

Prevention

When it happens

Trigger: Calling AutoPipeline() or AsyncAutoPipeline() on a *redis.Ring instance. UniversalClient code that branches on interface type and lands on a Ring. Migrating autopipeline code from a Client to a Ring-backed setup.

Common situations: Using UniversalClient and assuming all client types support autopipelining. Switching from a single-node Client to a Ring for client-side sharding without realizing autopipelining isn't supported there. Copying autopipeline code from a Client example into Ring code.

Related errors


AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06). Data as JSON: /data/errors/6c83ef3086c5acab.json. Report an issue: GitHub.