Skip to content

Multiple Redis 6.0/6.2 commands fail without version compatibility check #3207

@KoKimSS

Description

@KoKimSS

Summary

Spring Data Redis 2.6+ introduces support for Redis 6.0/6.2 commands but lacks version compatibility checks, causing runtime failures when these methods are used against older Redis servers.

Current Behavior

The following Spring Data Redis methods directly send Redis 6.0/6.2 commands without checking server version compatibility:

Redis 6.0+ Commands (failing on Redis < 6.0)

  • redisTemplate.copy(sourceKey, targetKey)ERR unknown command 'COPY'
  • redisTemplate.opsForList().move(src, dest, direction)ERR unknown command 'LMOVE'
  • redisTemplate.opsForZSet().randomMember(key)ERR unknown command 'ZRANDMEMBER'
  • redisTemplate.opsForHash().randomField(key)ERR unknown command 'HRANDFIELD'
  • redisTemplate.opsForSet().isMember(key, members...)ERR unknown command 'SMISMEMBER'

Redis 6.2+ Commands (failing on Redis < 6.2)

  • redisTemplate.opsForValue().getAndDelete(key)ERR unknown command 'GETDEL'
  • redisTemplate.opsForValue().getAndExpire(key, timeout)ERR unknown command 'GETEX'
  • redisTemplate.opsForZSet().score(key, members...)ERR unknown command 'ZMSCORE'

Expected Behavior

  • Automatic detection of Redis server version capabilities
  • Graceful fallback to equivalent command combinations for unsupported commands
  • No runtime failures due to version incompatibilities

Reproduction Steps

  1. Set up Redis server < 6.0 or < 6.2
  2. Use Spring Data Redis 2.6+
  3. Call any of the affected methods listed above
  4. Observe ERR unknown command exceptions

Environment

  • Spring Data Redis: 2.6+
  • Redis Server: < 6.0 or < 6.2 depending on command
  • Impact: Production environments using legacy Redis versions

Existing Patterns

Spring Data Redis already implements similar version-based compatibility for:

  • SCAN vs KEYS command selection
  • EVALSHA with automatic fallback to EVAL

Contribution Interest

I would be interested in contributing a solution for this issue if the Spring Data Redis team considers this a valid enhancement.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions