Built-in Redis cache does not gracefully degrade on connection failure, leading to fatal errors

bzcomputers

Well-known member
Affected version
2.0+
When the built-in Redis cache provider is configured and Redis becomes temporarily unavailable (e.g., during a service restart or brief outage), XenForo throws an uncaught RedisException, resulting in a fatal error that makes the entire site inaccessible. This occurs early in the bootstrap process during DataRegistry operations, preventing the site from loading any content until Redis recovers.

Expected: The system should degrade gracefully by falling back to a non-Redis cache (e.g., file-based or null) for the duration of the outage, keeping the site at least operational, albeit slower.

Expected Behavior​

  • Catch Redis connection exceptions in early cache reads (e.g., DataRegistry).
  • Fallback to a built-in alternative cache (e.g., Filesystem or Null) for the request.
  • Log the exception without halting execution.
  • Keep the site accessible during short Redis outages.

Actual Behavior​

  • Uncaught RedisException propagates from the provider.
  • Fatal error halts bootstrap — full site downtime until Redis is restored.
  • Nothing logged within XenForo.

Suggested Fix​

  • Wrap cache calls with try/catch for RedisException/CacheException.
  • On catch, switch to fallback provider (e.g., new \XF\Cache\FilesystemAdapter).
  • Log: \XF::logException($e, false);
  • Add config option: $config['cache']['failure_fallback'] = 'Filesystem'; (default: none/throw).
 
Back
Top Bottom