instructure/canvas-lms · error · CanvasCache::Redis::UnsupportedRedisMethod
Redis method `# ` is not supported by Twemproxy, and so…
Error message
Redis method `#{command}` is not supported by Twemproxy, and so shouldn't be used in Canvas What it means
canvas_cache's Twemproxy adapter blocks Redis commands that Twemproxy cannot route (per UNSUPPORTED_METHODS, e.g. KEYS, SCAN-like multi-node ops, transactions) by raising UnsupportedRedisMethod. Because Canvas runs Redis behind Twemproxy in production, unsupported commands would silently misbehave, so they're rejected with a clear message instead.
Solutions
- Rewrite the code to use supported commands (e.g. SCAN via per-key patterns, pipelined gets) instead of blocked ones
- Use a direct (non-Twemproxy) Redis connection for administrative/maintenance commands
- Set RedisClient.dangerous_redis_methods_allowed? / run in GuardRail :deploy environment only if the command is genuinely needed and safe
- Check UNSUPPORTED_METHODS in the gem to confirm which commands are blocked and pick alternatives
Example fix
// before
keys = redis.keys('course:cities:*')
// after
keys = redis.scan_each(match: 'course:cities:*').to_a # supported variant
Defensive patterns
Strategy: validation
Validate before calling
UNSAFE = %w[KEYS SCAN MULTI EXEC].freeze raise UnsupportedRedisMethod, cmd if UNSAFE.include?(cmd.to_s.upcase)
Try / catch
begin
redis.keys(pattern)
rescue CanvasCache::Redis::UnsupportedRedisMethod => e
Rails.logger.warn("twemproxy: #{e.message}")
fallback_supported_scan(pattern)
end Prevention
- Review canvas_cache UNSUPPORTED_METHODS before using exotic Redis commands
- Prefer pipelined simple commands over multi-key/transactional ops
- Test redis-dependent code against a Twemproxy-proxied instance
When it happens
Trigger: Calling an unsupported Redis command (e.g. redis.keys('*'), multi/exec, script ops in some setups) through a redis-client configured with the Twemproxy adapter; check_command is invoked by call and call_pipelined.
Common situations: Debugging in console against production-style proxy config; gems/libraries issuing commands that assume direct Redis access; using methods that work locally but not behind Twemproxy after deploying.
Related errors
- Redis method `# ` is potentially dangerous, and should only…
- an object with an interface for loading settings must be…
- CANVAS_HTTP CB_TRIP ON #
- max number of clients reached
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/45e0861d33b1bcd3.
Report an issue: GitHub.
Appendix: source
Thrown at gems/canvas_cache/lib/redis_client/twemproxy.rb:103
slowlog
sync
].freeze
def call(command, _config)
check_command(command.first.to_s)
super
end
def call_pipelined(commands, _config)
commands.each do |command|
check_command(command.first.to_s)
end
super
end
def check_command(command)
if UNSUPPORTED_METHODS.include?(command)
raise CanvasCache::Redis::UnsupportedRedisMethod,
"Redis method `#{command}` is not supported by Twemproxy, and so shouldn't be used in Canvas"
end
if ALLOWED_UNSUPPORTED.include?(command) && !RedisClient.dangerous_redis_methods_allowed? && GuardRail.environment != :deploy
raise CanvasCache::Redis::UnsupportedRedisMethod,
"Redis method `#{command}` is potentially dangerous, and should only be called from console, and only if you fully understand the consequences. If you're sure, retry after wrapping in `RedisClient.with_dangerous_redis_methods`"
end
end
end
end
View on GitHub (pinned to 1c9f0bb801)